Java Reference
In-Depth Information
14:18:30.720 [main] INFO chapter6.ApacheLogging - fundAmount = 11000.0
14:18:30.720 [main] TRACE chapter6.ApacheLogging - exit
14:18:30.720 [main] TRACE chapter6.ApacheLogging - entry
14:18:30.720 [main] INFO chapter6.ApacheLogging - fundAmount = 11000.0
14:18:30.720 [main] TRACE chapter6.ApacheLogging - exit
14:18:30.720 [main] TRACE chapter6.ApacheLogging - entry
14:18:30.720 [main] INFO chapter6.ApacheLogging - fundAmount = 11000.0
14:18:30.720 [main] TRACE chapter6.ApacheLogging - exit
14:18:30.720 [main] TRACE chapter6.ApacheLogging - entry
14:18:30.720 [main] INFO chapter6.ApacheLogging - fundAmount = 11000.0
14:18:30.720 [main] TRACE chapter6.ApacheLogging - exit
David Johnson will have $41.666666666666664 per month for retirement.
14:18:30.720 [main] FATAL chapter6.ApacheLogging - monthlyPension is too low
14:18:30.720 [main] TRACE chapter6.ApacheLogging - finely detailed TRACE message
14:18:30.721 [main] DEBUG chapter6.ApacheLogging - detailed DEBUG message
14:18:30.721 [main] INFO chapter6.ApacheLogging - informational message
14:18:30.721 [main] WARN chapter6.ApacheLogging - warning message
14:18:30.721 [main] ERROR chapter6.ApacheLogging - error message
14:18:30.721 [main] FATAL chapter6.ApacheLogging - fatal message
15. Remember how you set up file handlers at different levels and with different output files in the previous
example? You can do the same thing here, in the configuration file, by adding and editing appenders,
files, and loggers. In the configuration file, under </Console> , add two new files to the appenders sec-
tion. In the code here, ApacheLog-Warn is stored at c:/users/n12063/ApacheLogging_Warn.log .
Make sure you use a filename that indicates a usable location on your own computer.
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36}
- %msg%n"/>
</Console>
<File name="ApacheLog-Info" filename=
"c:/users/n12063/ApacheLogging_Info.log">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1}
- %msg%n</pattern>
</PatternLayout>
</File>
<File name="ApacheLog-Warn" filename="src/ApacheLogging_Warn.log">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1}
- %msg%n</pattern>
</PatternLayout>
</File>
</Appenders>
16. Next, adjust the loggers section to add these new appenders to the root logger.
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" level="fatal"/>
<AppenderRef ref="ApacheLog-Info" level="info"/>
<AppenderRef ref="ApacheLog-Warn" level="warn"/>
</Root>
</Loggers>
Search WWH ::




Custom Search