Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public class Log4jInit extends HttpServlet{
  2.  
  3. private static final long serialVersionUID = 1L;
  4.  
  5. public void init(){
  6.  
  7. String file = getInitParameter(Constantes.LOG4JINIT);
  8.  
  9. try{
  10. if(file != null){
  11. Properties props = new Properties();
  12. props.load(new FileInputStream(file));
  13. PropertyConfigurator.configure(props);
  14. }
  15.  
  16. } catch (FileNotFoundException e) {
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. } catch (IOException e) {
  20. // TODO Auto-generated catch block
  21. e.printStackTrace();
  22. }
  23. }
  24.  
  25. <servlet>
  26. <servlet-name>log4j-init</servlet-name>
  27. <servlet-class>es.elcorteingles.n005.utils.Log4jInit</servlet-class>
  28. <init-param>
  29. <param-name>log4j-init-file</param-name>
  30. <param-value>classpath:log4j.properties</param-value>
  31. </init-param>
  32. <load-on-startup>1</load-on-startup>
  33. </servlet>
  34.  
  35. <resource>
  36. <directory>src/main/resource</directory>
  37. <targetPath>${project.build.directory}</targetPath>
  38. <filtering>true</filtering>
  39. <includes>
  40. <include>**/*.properties</include>
  41. </includes>
  42. </resource>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement