We help IT Professionals succeed at work.
Get Started

Log4J Console Appender

directxBOB
directxBOB asked
on
1,438 Views
Last Modified: 2012-05-11
I have the following Log4J Properties file:

log4j.rootLogger=ERROR, fileAppender, consoleAppender

log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%m%n
log4j.appender.consoleAppender.Threshold=INFO

log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} - %-5p [%t] - %c#%M: %m%n
log4j.appender.fileAppender.File=/myLogs/server.log
log4j.appender.fileAppender.MaxFileSize=10MB
log4j.appender.fileAppender.MaxBackupIndex=5

log4j.logger.test.class=INFO

The problems that I am currently experiencing are:

1. The console log can grow indefinitely. I came in after the weekend and found the log file was 90gigs....

2. At the bottom of the file I am setting: log4j.logger.test.class=INFO
This ensures that I have the right package level for all by logging, but if I set this to DEBUG everything gets out putted to the Console log, which is obviously not ideal.

What I would like is that I can some how control the max size of the console log and split it to multiple files if needed.
Secondly I want to make sure that only INFO information goes to the logs.

I'm not finding a huge amount on console appenders

Thanks
Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 3 Answers and 11 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE