Permalink
Browse files

Logging enhancements.

# Allows to direct the logs to files along with the console.
# Adds logack config file fo more flexible logging.
  • Loading branch information...
CodeCramp committed Mar 20, 2018
1 parent 85045c3 commit 2d70f2d67e024adc774f8e14c5c6d536fba1f6f3
Showing with 35 additions and 0 deletions.
  1. +3 −0 build.gradle
  2. 0 resources/hellogradle.log
  3. +32 −0 resources/logback.xml
@@ -6,6 +6,9 @@ sourceSets {
java {
srcDirs = ['src/com/codecramp']
}
resources {
srcDir = ['resources']
}
}
}

No changes.
@@ -0,0 +1,32 @@
<configuration>
<!-- Appender specifies the output location of the logs -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<!-- Keeping file in resources folder for quick access, usually it is some shared location
where everyone could see the logs, in case, anything goes wrong. -->
<file>resources/hellogradle.log</file>
<!-- Appends the new log messages in the same file -->
<append>true</append>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</encoder>
</appender>
<!-- Generally, the level attribute is not necessary since -->
<!-- the level of the root is set to DEBUG by default. -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<!-- <appender-ref ref="STDOUT" /> -->
</root>
<!-- Setting com.codecramp.greeting to DEBUG -->
<logger name="consoleLogger" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
</configuration>

0 comments on commit 2d70f2d

Please sign in to comment.