RollingFileAppender vs CompositeRollingAppender

2012-10-05 Thread Praveen Sake
 Hi,

In our project we are using both RollingFileAppender and
CompositeFileAppender. Both these class files are loaded into classpath,
but only RollingFileAppender is being detected. And, for
CompositeRollingAppender I'm getting ClassNotFound exception. Since both
these classes extent FileAppender class, is this related to some hierarchy
(parent/child) issue, where only high level class gets picked up? The
detailed log is given below, any thoughts? Appreciate your help.

Oct 5, 2012 4:14:10 PM com.sun.faces.config.ConfigureListener
contextInitialized
INFO: Initializing Sun's JavaServer Faces implementation (1.2_03-b04-FCS)
for context '/console'
Oct 5, 2012 4:14:10 PM com.sun.faces.config.ConfigureListener
contextInitialized
INFO: Completed initializing Sun's JavaServer Faces implementation
(1.2_03-b04-FCS) for context '/console'
log4j: Threshold =null.
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.hibernate] additivity to [false].
log4j: Level value for org.hibernate is  [error].
log4j: org.hibernate level set to ERROR
log4j: Class name: [org.apache.log4j.CompositeRollingAppender]
log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassNotFoundException: org.apache.log4j.CompositeRollingAppender
at
weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at
weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)
at
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:164)
at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
at
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
at
org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
at
org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
at
org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
at org.apache.log4j.LogManager.clinit(LogManager.java:113)
at org.apache.log4j.Logger.getLogger(Logger.java:85)
at
org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
at
org.apache.commons.logging.impl.Log4JLogger.init(Log4JLogger.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)
at
org.apache.beehive.netui.util.logging.Logger.getInstance(Logger.java:45)
at
org.apache.beehive.netui.pageflow.PageFlowUtils.clinit(PageFlowUtils.java:77)
at
com.bea.netuix.servlets.manager.AppDescriptor.loadDescriptor(AppDescriptor.java:1072)
at
com.bea.netuix.servlets.manager.SingleFileServlet.reinitInternal(SingleFileServlet.java:124)
at
com.bea.netuix.servlets.manager.SingleFileServlet.initInternal(SingleFileServlet.java:84)
at
com.bea.netuix.servlets.manager.SingleFileServlet.access$100(SingleFileServlet.java:48)
at
com.bea.netuix.servlets.manager.SingleFileServlet$ServletLifecycleListenerImpl.init(SingleFileServlet.java:278)
at
com.bea.netuix.util.ServletLifecycleListener.initOrReinitInternal(ServletLifecycleListener.java:131)
at
com.bea.netuix.util.ServletLifecycleService.addServletLifecycleListener(ServletLifecycleService.java:252)
at
com.bea.netuix.util.ServletLifecycleService.addServletLifecycleListener(ServletLifecycleService.java:182)
at
com.bea.netuix.servlets.manager.SingleFileServlet.init(SingleFileServlet.java:77)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)

Display line number of logfile in logfile

2012-10-05 Thread Jochen Hinrichsen

We are experiencing log entries being written to the wrong files using
DailyRollingFileAppender rotating on an hourly basis. In addition, file
sizes are changing between rollovers. We have massive log entries, 128
cores, and large files. The issue happens sporadic, and is not reproducible.

Now, before diving into the analysis, i wanted to log a number identifying
the log entry to make sure no entries get lost:

timestamp 01 log entry
timestamp 02 log entry
timestamp 03 log entry

After rolling to a fresh file:

timestamp 04 log entry

and so on. This line number (plus a little script) could verify that rolling
does not drop any entries.

I did not find a conversion character in PatternLayout. I do not want to use
L (Used to output the line number from where the logging request was
issued).

Any idea other than writing my own appender?

-- 
View this message in context: 
http://old.nabble.com/Display-line-number-of-logfile-in-logfile-tp34518214p34518214.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: RollingFileAppender vs CompositeRollingAppender

2012-10-05 Thread Praveen Sake
Hi Tim,

Thanks for your response. I already have both the CompositeFileAppender
class file in the classpath, and the log4j.jar (which has
RollingFileAppender class) in the classpath. But only the log4j.jar class
is getting loaded, but not the CompositeFileAppender class.

Regards,
Praveen

On Fri, Oct 5, 2012 at 5:54 PM, Tim Watts t...@cliftonfarm.org wrote:

 On Fri, 2012-10-05 at 16:32 +0530, Praveen Sake wrote:
  Hi,
 
  In our project we are using both RollingFileAppender and
  CompositeFileAppender. Both these class files are loaded into classpath,
  but only RollingFileAppender is being detected. And, for
  CompositeRollingAppender I'm getting ClassNotFound exception. Since both
  these classes extent FileAppender class, is this related to some
 hierarchy
  (parent/child) issue, where only high level class gets picked up? The
  detailed log is given below, any thoughts? Appreciate your help.
 

 There's no subtle trick here.  CompositeRollingAppender is not bundled
 in the distribution jar.  You would need to compile the source and put
 it somewhere in the classpath or in a jar in the classpath.


  Oct 5, 2012 4:14:10 PM com.sun.faces.config.ConfigureListener
  contextInitialized
  INFO: Initializing Sun's JavaServer Faces implementation (1.2_03-b04-FCS)
  for context '/console'
  Oct 5, 2012 4:14:10 PM com.sun.faces.config.ConfigureListener
  contextInitialized
  INFO: Completed initializing Sun's JavaServer Faces implementation
  (1.2_03-b04-FCS) for context '/console'
  log4j: Threshold =null.
  log4j: Retreiving an instance of org.apache.log4j.Logger.
  log4j: Setting [org.hibernate] additivity to [false].
  log4j: Level value for org.hibernate is  [error].
  log4j: org.hibernate level set to ERROR
  log4j: Class name: [org.apache.log4j.CompositeRollingAppender]
  log4j:ERROR Could not create an Appender. Reported error follows.
  java.lang.ClassNotFoundException:
 org.apache.log4j.CompositeRollingAppender
  at
 
 weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
  at
 
 weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
  at
 
 weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:169)
  at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)
  at
 
 org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:164)
  at
 
 org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
  at
 
 org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
  at
 
 org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
  at
 
 org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
  at
  org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
  at
 
 org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
  at
 
 org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
  at
 
 org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
  at
 
 org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
  at org.apache.log4j.LogManager.clinit(LogManager.java:113)
  at org.apache.log4j.Logger.getLogger(Logger.java:85)
  at
 
 org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
  at
  org.apache.commons.logging.impl.Log4JLogger.init(Log4JLogger.java:65)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
  Method)
  at
 
 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at
 
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at
 java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at
 
 org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
  at
 
 org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
  at
 org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)
  at
  org.apache.beehive.netui.util.logging.Logger.getInstance(Logger.java:45)
  at
 
 org.apache.beehive.netui.pageflow.PageFlowUtils.clinit(PageFlowUtils.java:77)
  at
 
 com.bea.netuix.servlets.manager.AppDescriptor.loadDescriptor(AppDescriptor.java:1072)
  at
 
 com.bea.netuix.servlets.manager.SingleFileServlet.reinitInternal(SingleFileServlet.java:124)
  at
 
 

Re: Log4j Extras ExpressionFilter issue

2012-10-05 Thread Jacob Kjome
When you added the URL to the marker field, did you add it with  or 
amp;?


When setting it via MDC, I'd be setting it as .  But, in XML, it must be 
escaped using amp; otherwise we'll get a parsing error, since  is a 
reserved character that defines the start of an entity reference.


In fact, I'm not sure how you were able to define level == info  
prop.marker=... without experiencing a parsing error, such as


log4j:WARN Fatal parsing error 15 and column 67
log4j:WARN The entity name must immediately follow the '' in the entity 
reference.

log4j:ERROR Could not parse url [file:./log4j.xml].
org.xml.sax.SAXParseException: The entity name must immediately follow the '' 
in the entity reference.
    at 
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
    at 
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
    at 
org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:769)
    at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:871)



In any case, if anything, I'd expect to see **no** TRACE output if it had 
trouble matching the value.  Instead, I see **all** trace output.  It's as if 
it were able to parse the LEVEL == TRACE part, but then silently ignore the 
rest of the configuration that, maybe, it was unable to parse?  Or maybe, it 
silently ignored the entire expression altogether, leaving me with only the 
fact that the TRACE level is enabled for the particular logger I am using, so 
the TRACE info was logged regardless.


In fact, the latter appears to be the case.  The expression is totally 
ignored.  I tried the following minimal expression, and I continued to get 
DEBUG info, as well as TRACE info...


    appender name=default 
class=org.apache.log4j.rolling.RollingFileAppender

    ...
    filter class=org.apache.log4j.filter.ExpressionFilter
    param name=Expression
   value=(level = info)/
    /filter
    /appender

Are you sure this thing works outside of Chainsaw?  I'm not using Chainsaw 
here, just logging to a RollingFileAppender in a command-line application.  
BTW, I'm also using SLF4J, binding to Log4j-1.2.17.



Jake

On Thu, 4 Oct 2012 15:38:59 -0700
 Scott Deboy scott.de...@gmail.com wrote:

Hey Jake

I tried this in the latest developer snapshot of Chainsaw..I pulled up a
log in Chainsaw which contained info and debug entries (I didn't have a log
with trace).

And I added your URL value you provided in the 'marker' field of two of my
INFO entries

This expression:

(level = debug) || (level == info  prop.marker == '
https://somedomain/somepath/somepage.do?someparam=somevalamp;anotherparam=anotherval
')

Gave me all of the debug entries and two info level entries..

It could be something weird with trace...or something weird with parsing
the amp; ??? but...this should work..

Scott


On Wed, Oct 3, 2012 at 8:56 AM, Jacob Kjome h...@visi.com wrote:



Thanks Scott,

However, while I didn't experience an error in parsing the expression this
time, the expression seems to be, at least partially, ignored.

Below is the relevant config, where com.mypackage.MyClass sets MDC (via
SLF4J) with a url key and the currently processed URL as the value, then
logs the page content for the URL at the TRACE level (with MDC removal of
url immediately after logging the page content).  But rather than getting
TRACE output for only the URL defined in the Expression, I get **all**
TRACE output.  It's like it sees the LEVEL == TRACE but then ignores the
.  Thoughts?


 appender name=default class=org.apache.log4j.**
rolling.RollingFileAppender
 ...

 filter class=org.apache.log4j.**filter.ExpressionFilter
 param name=Expression
value=( LEVEL = DEBUG ) || ( LEVEL == TRACE
amp;amp; PROP.url == 'https://somedomain/somepath/**
somepage.do?someparam=someval**amp;anotherparam=anothervalhttps://somedomain/somepath/somepage.do?someparam=somevalanotherparam=anotherval'
)/
 /filter
 /appender

 logger name=com.mypackage.MyClass
 level value=TRACE/
 /logger

 root
 level value=WARN/
 appender-ref ref=default/
 /root



On Tue, 2 Oct 2012 15:53:57 -0700
  Scott Deboy scott.de...@gmail.com wrote:


Try PROP.url == 'blah'

MDC entries are really just set as properties of the log4j events.

Scott

On Tue, Oct 2, 2012 at 1:10 PM, Jacob Kjome h...@visi.com wrote:



I'm trying to use the ExpressionFilter [1] from Log4j Extras to limit
logging for a particular appender to those cases where MDC contains a
url
entry that equals some specific value.  But I get an error from Log4j
saying Invalid EQUALS rule - MDC.url is not a supported field (see
below
for complete error output from Log4j).  I'm using the latest versions of
Log4j-1.x and Log4j-extras.  Here's the relevant config...

appender...
  
  filter 

Re: Log4j Extras ExpressionFilter issue

2012-10-05 Thread Jacob Kjome


Here's the relevant Log4j debug output (no error thrown upon parsing, as you 
can see)...


log4j: Class name: [org.apache.log4j.rolling.RollingFileAppender]
log4j: Setting property [fileNamePattern] to [./logs/myapp.%d.log.gz].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} [%-5p][%-8.8t]: 
%39.39c - %m%n].

log4j: Setting property [expression] to [(level = info)].
log4j: Adding filter of type [class org.apache.log4j.filter.ExpressionFilter] 
to appender named [default].

log4j: setFile called: ./logs/myapp.2012-10-05.log, true
log4j: setFile ended
log4j: Adding appender named [default] to category [root].


Yet, I get TRACE and DEBUG output in the log file.  I even tried a second run, 
removing the parens and had just level = info.  Same thing.  I still get 
TRACE and DEBUG output when I've clearly specified in the expression that it 
should filter everything but INFO and above.



Jake

On Fri, 5 Oct 2012 13:47:27 -0700
 Scott Deboy scott.de...@gmail.com wrote:

Right, in the XML it has to be escaped for the filter.  Chainsaw uses the
same expression-handling code the ExpressionFilter uses (ExpressionRule),
which is why as long as the xml parsing is working as expected it should be
an equivalent test.  ExpressionRule throws an exception if the expression
couldn't be parsed, so if you turned on -Dlog4j.debug you'd see an error
when the ExpressionFilter parsing happens.

Scott

On Fri, Oct 5, 2012 at 1:38 PM, Jacob Kjome h...@visi.com wrote:


When you added the URL to the marker field, did you add it with  or
amp;?

When setting it via MDC, I'd be setting it as .  But, in XML, it must
be escaped using amp; otherwise we'll get a parsing error, since  is
a reserved character that defines the start of an entity reference.

In fact, I'm not sure how you were able to define level == info 
prop.marker=... without experiencing a parsing error, such as

log4j:WARN Fatal parsing error 15 and column 67
log4j:WARN The entity name must immediately follow the '' in the entity
reference.
log4j:ERROR Could not parse url [file:./log4j.xml].
org.xml.sax.SAXParseException: The entity name must immediately follow the
'' in the entity reference.
 at com.sun.org.apache.xerces.**internal.parsers.DOMParser.**
parse(DOMParser.java:249)
 at com.sun.org.apache.xerces.**internal.jaxp.**
DocumentBuilderImpl.parse(**DocumentBuilderImpl.java:284)
 at org.apache.log4j.xml.**DOMConfigurator$2.parse(**
DOMConfigurator.java:769)
 at org.apache.log4j.xml.**DOMConfigurator.doConfigure(**
DOMConfigurator.java:871)


In any case, if anything, I'd expect to see **no** TRACE output if it had
trouble matching the value.  Instead, I see **all** trace output.  It's as
if it were able to parse the LEVEL == TRACE part, but then silently
ignore the rest of the configuration that, maybe, it was unable to parse?
Or maybe, it silently ignored the entire expression altogether, leaving me
with only the fact that the TRACE level is enabled for the particular
logger I am using, so the TRACE info was logged regardless.

In fact, the latter appears to be the case.  The expression is totally
ignored.  I tried the following minimal expression, and I continued to get
DEBUG info, as well as TRACE info...


 appender name=default class=org.apache.log4j.**
rolling.RollingFileAppender
 ...
 filter class=org.apache.log4j.**filter.ExpressionFilter
 param name=Expression
value=(level = info)/
 /filter
 /appender

Are you sure this thing works outside of Chainsaw?  I'm not using Chainsaw
here, just logging to a RollingFileAppender in a command-line application.
BTW, I'm also using SLF4J, binding to Log4j-1.2.17.


Jake


On Thu, 4 Oct 2012 15:38:59 -0700
  Scott Deboy scott.de...@gmail.com wrote:


Hey Jake

I tried this in the latest developer snapshot of Chainsaw..I pulled up a
log in Chainsaw which contained info and debug entries (I didn't have a
log
with trace).

And I added your URL value you provided in the 'marker' field of two of my
INFO entries

This expression:

(level = debug) || (level == info  prop.marker == '
https://somedomain/somepath/**somepage.do?someparam=someval**
amp;anotherparam=anothervalhttps://somedomain/somepath/somepage.do?someparam=somevalanotherparam=anotherval
')

Gave me all of the debug entries and two info level entries..

It could be something weird with trace...or something weird with parsing
the amp; ??? but...this should work..

Scott


On Wed, Oct 3, 2012 at 8:56 AM, Jacob Kjome h...@visi.com wrote:



Thanks Scott,

However, while I didn't experience an error in parsing the expression
this
time, the expression seems to be, at least partially, ignored.

Below is the relevant config, where com.mypackage.MyClass sets MDC (via
SLF4J) with a url key and the currently processed URL as the value,
then
logs the page content for the URL at the TRACE level (with