Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rohit Bajaj

ASKER

what should i set it to ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial