• log4j xml配置



    1. <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    2. <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
    3. <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
    4. <layout class="org.apache.log4j.PatternLayout">
    5. <param name="ConversionPattern" value="%d{yyyy-M-d HH:mm:ss}%x[%5p %t](%c:%3L) %m%n" />
    6. </layout>
    7. </appender>
    8. <!-- 输出日志到文件 每天一个文件 -->
    9. <appender name="dailyRollingFile"
    10. class="org.apache.log4j.DailyRollingFileAppender">
    11. <param name="Threshold" value="info"></param>
    12. <param name="ImmediateFlush" value="true"></param>
    13. <param name="File" value="d:/logs/dailyRollingFile.log"></param>
    14. <param name="DatePattern" value="'.'yyyy-MM-dd'.log'"></param>
    15. <layout class="org.apache.log4j.PatternLayout">
    16. <param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss} %-5p] [%t] {%c:%L}-%m%n"></param>
    17. </layout>
    18. </appender>
    19. <!-- 输出日志到文件 文件大小到达指定尺寸的时候产生一个新的文件 -->
    20. <appender name="railyFile"
    21. class="org.apache.log4j.RollingFileAppender">
    22. <param name="File" value="d:/logs/railyFile.log"></param>
    23. <param name="ImmediateFlush" value="true"/>
    24. <param name="Threshold" value="info"></param>
    25. <param name="Append" value="true"></param>
    26. <param name="MaxFileSize" value="30KB"></param>
    27. <param name="MaxBackupIndex" value="100"></param>
    28. <layout class="org.apache.log4j.PatternLayout">
    29. <param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss} %-5p] [%t] {%c:%L}-%m%n"></param>
    30. </layout>
    31. </appender>
    32. <!--然后定义logger,只有定义了logger并引入的appender,appender才会生效 -->
    33. <logger name="org.quartz">
    34. <level value="error" />
    35. </logger>
    36. <logger name="org.springframework.cache">
    37. <level value="info" />
    38. </logger>
    39. <logger name="org.apache">
    40. <level value="error" />
    41. </logger>
    42. <logger name="com.opensymphony.xwork2">
    43. <level value="error" />
    44. </logger>
    45. <!-- Do1平台日志 -->
    46. <logger name="cn.com.do1">
    47. <level value="debug" />
    48. </logger>
    49. <!-- 控制台输出日志 -->
    50. <root>
    51. <level value="info" />
    52. <appender-ref ref="ConsoleAppender" />
    53. <appender-ref ref="dailyRollingFile" />
    54. <appender-ref ref="railyFile" />
    55. </root>
    56. </log4j:configuration>

  • 相关阅读:
    POJ 1511
    POJ 1125
    POJ 2240
    POJ 1459
    POJ 1274
    POJ 1789
    POJ 2485,1258
    POJ 1236
    POJ 1273
    Ruby on Rails 观后感
  • 原文地址:https://www.cnblogs.com/signheart/p/6597933.html
Copyright © 2020-2023  润新知