German
German

Reputation: 3606

Disable Struts2 logs

How can I disable Struts2 zillions of logs?

I constantly get logs like this:

2012-04-12 23:20:31,487 DEBUG [XWorkConverter.java:388] : Property: menuExpandedOps

I'm using struts 2.0 and standard java logging (I'm not using log4j).

The logging.properties file of the JVM is set by default to INFO, and I already have struts.devMode = false in my struts.properties file.

Upvotes: 3

Views: 3627

Answers (2)

k_rollo
k_rollo

Reputation: 5472

and a simple property file/xml file in class-path can help you to turn on or off the logging information.

For those who want an example:

1) Put log4j.properties inside src (where your packages are):

enter image description here

2) Turn OFF low-level logging:

# root logger option
log4j.rootLogger=DEBUG, stdout, file

# direct log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%p: %d{yyyy-MM-dd HH:mm:ss} %F:%L] %m%n

# direct log messages to a log file, support file rolling
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/sortingmonitor.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%p: %d{yyyy-MM-dd HH:mm:ss} %F:%L] %m%n

# disable apache low level logging
log4j.category.com.opensymphony.xwork2=OFF
log4j.category.org.apache.struts2=OFF
log4j.category.freemarker.beans=OFF
log4j.category.freemarker.cache=OFF

Further reading for XML: http://deepaksrivastav.github.io/blog/2011/01/06/disable-struts-2-log-messages/

Upvotes: 1

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

If you are free to use log4j, i suggest you to use that, since Log4j has the ability to set different log levels for different packages and hence using the log level OFF we can disable logging for a particular package.

In S2 most of the log messages will be from these packages

  • xwork2
  • struts2
  • freemarker
  • ognl

and a simple property file/xml file in class-path can help you to turn on or off the logging information.

Upvotes: 3

Related Questions