Advertisement
Guest User

Untitled

a guest
Aug 20th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. --------------PROBLEM--------------
  2. No matter what I do log4j2 wont find the configuration file in the class path. gives this error:
  3.  
  4. ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
  5.  
  6. --------------PROJECT STRUCTURE--------------
  7. Testing
  8. src
  9. main
  10. java
  11. testing
  12. App
  13. resources
  14. log4j2.yml
  15. pom.xml
  16.  
  17. --------------pom.xml--------------
  18.  
  19. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  21. <modelVersion>4.0.0</modelVersion>
  22.  
  23. <groupId>testing</groupId>
  24. <artifactId>testingid</artifactId>
  25. <version>1.0-SNAPSHOT</version>
  26. <packaging>jar</packaging>
  27.  
  28. <name>testingid</name>
  29. <url>http://maven.apache.org</url>
  30.  
  31. <properties>
  32. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  33. </properties>
  34.  
  35. <dependencies>
  36. <dependency>
  37. <groupId>junit</groupId>
  38. <artifactId>junit</artifactId>
  39. <version>3.8.1</version>
  40. <scope>test</scope>
  41. </dependency>
  42. <dependency>
  43. <groupId>org.apache.logging.log4j</groupId>
  44. <artifactId>log4j-api</artifactId>
  45. <version>2.6.2</version>
  46. </dependency>
  47. <dependency>
  48. <groupId>org.apache.logging.log4j</groupId>
  49. <artifactId>log4j-core</artifactId>
  50. <version>2.6.2</version>
  51. </dependency>
  52. </dependencies>
  53.  
  54. <build>
  55. <plugins>
  56. <plugin>
  57. <groupId>org.codehaus.mojo</groupId>
  58. <artifactId>exec-maven-plugin</artifactId>
  59. <version>1.5.0</version>
  60. <configuration>
  61. <mainClass>testing.App</mainClass>
  62. </configuration>
  63. </plugin>
  64. </plugins>
  65. </build>
  66. </project>
  67.  
  68. --------------App.java--------------
  69.  
  70. package testing;
  71.  
  72. import org.apache.logging.log4j.LogManager;
  73. import org.apache.logging.log4j.Logger;
  74.  
  75. public class App
  76. {
  77.  
  78. private final static Logger logger = LogManager.getLogger();
  79.  
  80. public static void main( String[] args )
  81. {
  82. System.out.println( "Hello World!" );
  83. }
  84. }
  85.  
  86. --------------log4j2.yml--------------(copied from some tutorial, i have also tried an xml file instead same result)
  87.  
  88. configuration:
  89. name: Default
  90. properties:
  91. property:
  92. - name: log-path
  93. value: logs
  94. - name: archive
  95. value: ${log-path}/archive
  96. appenders:
  97. Console:
  98. PatternLayout:
  99. pattern: '[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n'
  100. name: Console-Appender
  101. target: SYSTEM_OUT
  102. File:
  103. PatternLayout:
  104. pattern: '[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n'
  105. fileName: ${log-path}/logfile.log
  106. name: File-Appender
  107. RollingFile:
  108. DefaultRolloverStrategy:
  109. max: '30'
  110. PatternLayout:
  111. pattern: '[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n'
  112. Policies:
  113. SizeBasedTriggeringPolicy:
  114. size: 1 KB
  115. fileName: ${log-path}/rollingfile.log
  116. filePattern: ${archive}/rollingfile.log.%d{yyyy-MM-dd-hh-mm}.gz
  117. name: RollingFile-Appender
  118. loggers:
  119. logger:
  120. additivity: 'false'
  121. appender-ref:
  122. - level: info
  123. ref: Console-Appender
  124. - level: error
  125. ref: File-Appender
  126. - level: debug
  127. ref: RollingFile-Appender
  128. level: debug
  129. name: guru.springframework.blog.log4j2json
  130. root:
  131. appender-ref:
  132. ref: Console-Appender
  133. level: debug
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement