log4j configuration ideal for production

HI,
My current setting for log4j is :
# Root logger option
log4j.rootLogger=DEBUG, file

# Redirect 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=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Redirect log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/Users/robinsuri/Checkout/flock-snippets/flock-snippets.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Open in new window


I found that this is generating very large log file . some sample log :
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/tag-class'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for CallMethodRule[methodName=setTagClass, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG sax:101 - characters(org.apache.taglibs.standard.tag.rt.fmt.ParamTag)
2015-11-20 17:55:01 DEBUG sax:101 - endElement(http://java.sun.com/xml/ns/j2ee,tag-class,tag-class)
2015-11-20 17:55:01 DEBUG Digester:101 -   match='taglib/tag/tag-class'
2015-11-20 17:55:01 DEBUG Digester:101 -   bodyText='org.apache.taglibs.standard.tag.rt.fmt.ParamTag'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire body() for CallMethodRule[methodName=setTagClass, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 -   Popping body text '
        
        
        '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire end() for CallMethodRule[methodName=setTagClass, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 - [CallMethodRule]{taglib/tag/tag-class} Call org.apache.tomcat.util.descriptor.tld.TagXml.setTagClass(org.apache.taglibs.standard.tag.rt.fmt.ParamTag/java.lang.String)
2015-11-20 17:55:01 DEBUG IntrospectionUtils:101 - IntrospectionUtils:org.apache.tomcat.util.descriptor.tld.TagXml.setTagClass( org.apache.taglibs.standard.tag.rt.fmt.ParamTag)
2015-11-20 17:55:01 DEBUG sax:101 - characters(
        )
2015-11-20 17:55:01 DEBUG sax:101 - startElement(http://java.sun.com/xml/ns/j2ee,body-content,body-content)
2015-11-20 17:55:01 DEBUG Digester:101 -   Pushing body text '
        
        
        
        '
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/body-content'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for CallMethodRule[methodName=setBodyContent, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG sax:101 - characters(JSP)
2015-11-20 17:55:01 DEBUG sax:101 - endElement(http://java.sun.com/xml/ns/j2ee,body-content,body-content)
2015-11-20 17:55:01 DEBUG Digester:101 -   match='taglib/tag/body-content'
2015-11-20 17:55:01 DEBUG Digester:101 -   bodyText='JSP'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire body() for CallMethodRule[methodName=setBodyContent, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 -   Popping body text '
        
        
        
        '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire end() for CallMethodRule[methodName=setBodyContent, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 - [CallMethodRule]{taglib/tag/body-content} Call org.apache.tomcat.util.descriptor.tld.TagXml.setBodyContent(JSP/java.lang.String)
2015-11-20 17:55:01 DEBUG IntrospectionUtils:101 - IntrospectionUtils:org.apache.tomcat.util.descriptor.tld.TagXml.setBodyContent( JSP)
2015-11-20 17:55:01 DEBUG sax:101 - characters(
        )
2015-11-20 17:55:01 DEBUG sax:101 - startElement(http://java.sun.com/xml/ns/j2ee,attribute,attribute)
2015-11-20 17:55:01 DEBUG Digester:101 -   Pushing body text '
        
        
        
        
        '
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/attribute'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for org.apache.tomcat.util.descriptor.tld.TldRuleSet$TagAttributeRule@711f39f9
2015-11-20 17:55:01 DEBUG sax:101 - characters(
            )
2015-11-20 17:55:01 DEBUG sax:101 - startElement(http://java.sun.com/xml/ns/j2ee,description,description)
2015-11-20 17:55:01 DEBUG Digester:101 -   Pushing body text '
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/attribute/description'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for CallMethodRule[methodName=setDescription, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG sax:101 - characters(
                Argument used for parametric replacement.
            )
2015-11-20 17:55:01 DEBUG sax:101 - endElement(http://java.sun.com/xml/ns/j2ee,description,description)
2015-11-20 17:55:01 DEBUG Digester:101 -   match='taglib/tag/attribute/description'
2015-11-20 17:55:01 DEBUG Digester:101 -   bodyText='
                Argument used for parametric replacement.
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire body() for CallMethodRule[methodName=setDescription, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 -   Popping body text '
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire end() for CallMethodRule[methodName=setDescription, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 - [CallMethodRule]{taglib/tag/attribute/description} Call org.apache.tomcat.util.descriptor.tld.TldRuleSet$Attribute.setDescription(Argument used for parametric replacement./java.lang.String)
2015-11-20 17:55:01 DEBUG IntrospectionUtils:101 - IntrospectionUtils:org.apache.tomcat.util.descriptor.tld.TldRuleSet$Attribute.setDescription( Argument used for parametric replacement.)
2015-11-20 17:55:01 DEBUG sax:101 - characters(
            )
2015-11-20 17:55:01 DEBUG sax:101 - startElement(http://java.sun.com/xml/ns/j2ee,name,name)
2015-11-20 17:55:01 DEBUG Digester:101 -   Pushing body text '
            
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/attribute/name'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for CallMethodRule[methodName=setName, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG sax:101 - characters(value)
2015-11-20 17:55:01 DEBUG sax:101 - endElement(http://java.sun.com/xml/ns/j2ee,name,name)
2015-11-20 17:55:01 DEBUG Digester:101 -   match='taglib/tag/attribute/name'
2015-11-20 17:55:01 DEBUG Digester:101 -   bodyText='value'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire body() for CallMethodRule[methodName=setName, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 -   Popping body text '
            
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire end() for CallMethodRule[methodName=setName, paramCount=0, paramTypes={java.lang.String}]
2015-11-20 17:55:01 DEBUG Digester:101 - [CallMethodRule]{taglib/tag/attribute/name} Call org.apache.tomcat.util.descriptor.tld.TldRuleSet$Attribute.setName(value/java.lang.String)
2015-11-20 17:55:01 DEBUG IntrospectionUtils:101 - IntrospectionUtils:org.apache.tomcat.util.descriptor.tld.TldRuleSet$Attribute.setName( value)
2015-11-20 17:55:01 DEBUG sax:101 - characters(
            )
2015-11-20 17:55:01 DEBUG sax:101 - startElement(http://java.sun.com/xml/ns/j2ee,required,required)
2015-11-20 17:55:01 DEBUG Digester:101 -   Pushing body text '
            
            
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   New match='taglib/tag/attribute/required'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire begin() for org.apache.tomcat.util.descriptor.tld.TldRuleSet$GenericBooleanRule@71bbf57e
2015-11-20 17:55:01 DEBUG sax:101 - characters(false)
2015-11-20 17:55:01 DEBUG sax:101 - endElement(http://java.sun.com/xml/ns/j2ee,required,required)
2015-11-20 17:55:01 DEBUG Digester:101 -   match='taglib/tag/attribute/required'
2015-11-20 17:55:01 DEBUG Digester:101 -   bodyText='false'
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire body() for org.apache.tomcat.util.descriptor.tld.TldRuleSet$GenericBooleanRule@71bbf57e
2015-11-20 17:55:01 DEBUG Digester:101 -   Popping body text '
            
            
            '
2015-11-20 17:55:01 DEBUG Digester:101 -   Fire end() for org.apache.tomcat.util.descriptor.tld.TldRuleSet$GenericBooleanRule@71bbf57e
2015-11-20 17:55:01 DEBUG sax:101 - characters(

Open in new window


Dont know from where all these logs are getting generated. Files seem to be quickly reach 5 MB .
what is the ideal log4j configuration will you reccomend for production environment.

Thanks
Rohit BajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gurpsbassiCommented:
you have log4j.rootLogger=DEBUG

You don't want to be running in debug on production.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rohit BajajAuthor Commented:
what should i set it to ?
0
srikoteshCommented:
u can use Trace instead of debug.
whenever u want to see debug statements change it from trace to debug.
see logger level hierarchy in Google
0
Rohit BajajAuthor Commented:
Hi,
It looks like TRACE produces even more logs as it is at a higher level than debug.
https://logging.apache.org/log4j/2.0/manual/architecture.html
If i use info then logs are very less.
But if want to debug something so it looks like i should put logging in code like log.info instead of debug. As debug is producing lot of other unneccesary logging
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Yes, you should probably set it to something like INFO and then any logging statements that YOU write that you normally DO want to see in the log file, log them as INFO too. Or if it is a slightly abnormal situation you might log them at WARN level or if they are actually errors, you can log them at ERROR level, etc.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.