log4j does not require framework logs struts

我的梦境 提交于 2019-12-11 18:09:38

问题


I am creating a web application in struts2 using NetBeans IDE.

Now, i need to use log4j in my application and i have successfully created log4j.properties file under WEB-INF/classes.

This is my log4j.properties file :-

      # Define the root logger with appender file
        log4j.rootLogger = FATAL,FILE

        # Define the file appender
          log4j.appender.FILE=org.apache.log4j.FileAppender
          log4j.appender.FILE.File=F:\\Projects\\TinyStars\\NetbeansProject\\tinystarsbak\\web\\logs\\tinystar_log.out

         # Define the layout for file appender
        log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
        log4j.appender.FILE.layout.conversionPattern=[%-5p][%d{dd-MM-yyyy  HH:mm:ss}]%m%n

I have logged all my messages using appropriate log4j hierarchy like Debug, warn, error etc.

But along with my logging messages i am also getting thousands of (maybe framework related) logs. And this behavior is making my log file very bulky.

I strictly don't want any logs messages apart from what i give explicitly in my application.

Appreciate the help. Thanks in advance.


回答1:


Try this:

# Define the root logger with appender file
log4j.rootLogger = WARN,FILE

log4j.logger.your.package=DEBUG

It should set the default log level to WARN (ie for all frameworks), and DEGUB log level for your packages.



来源:https://stackoverflow.com/questions/11257059/log4j-does-not-require-framework-logs-struts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!