Re: FileAppender Truncates Stack Trace

2008-04-23 Thread Curt Arnold


On Apr 23, 2008, at 5:19 PM, Curt Arnold wrote:



The best way to add a custom rendering of the stack trace would be  
to write a custom appender (likely either wrapping or extending  
PatternLayout) which returns false ignoresThrowable() and then  
appends your custom equivalent to printStackTrace() the the result  
of the PatternLayout.format.



Corrections in CAPS:

The best way to add a custom rendering of the stack trace would be to  
write a custom appender (likely either wrapping or extending  
PatternLayout) which returns false FOR ignoresThrowable() and then  
appends your custom equivalent OF printStackTrace() TO the the result  
of the PatternLayout.format.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: FileAppender Truncates Stack Trace

2008-04-23 Thread Curt Arnold
Okay, I'm assuming that somewhere this exception is passed to log4j in  
something like:


try {
 ///
} catch(Exception ex) {
logger.info("Some app message", ex);
}

Using a standard layout, the stack trace will get rendered by  
WriterAppender.subAppend.


this.qw.write(this.layout.format(event));

if(layout.ignoresThrowable()) {
  String[] s = event.getThrowableStrRep();
  if (s != null) {
int len = s.length;
for(int i = 0; i < len; i++) {
  this.qw.write(s[i]);
  this.qw.write(Layout.LINE_SEP);
}
  }
}


Most appenders will return ignoreThrowable to true which will result  
in org.apache.log4j.spi.LoggingEvent;getThrowableStrRep() to render  
the exception which will eventually end up at  
org.apache.log4j.spi.ThrowableInformation.getThrowableStrRep() which  
will then call the printStackTrace() method of the exception.  The  
SymSQLException.printStackTrace() implementation (or the underlying  
JVM) is most likely the source of the ".. 14 more".


At least as I understand the situation, OnlyOnceErrorHandler would not  
be involved.  It would only be involved if the appender was raising  
exceptions and you mentioned using a FileAppender and a file appender  
should not be raising SQL exceptions.


A custom object renderer would not be useful unless the exception was  
used as the message parameter, which is probably not the case.


The best way to add a custom rendering of the stack trace would be to  
write a custom appender (likely either wrapping or extending  
PatternLayout) which returns false ignoresThrowable() and then appends  
your custom equivalent to printStackTrace() the the result of the  
PatternLayout.format.




On Apr 23, 2008, at 3:28 PM, Matthew Kemp wrote:

You can create your own custom object renderer that will properly  
render the

whole stack trace. This renderer will need to be included in the log4j
config and be available on the classpath when log4j initializes.


On Wed, Apr 23, 2008 at 3:19 PM, Robert Pepersack <
[EMAIL PROTECTED]> wrote:


Hello,

I'm using FileAppender to log to a log file.  When an exception gets
caught and printed, the stack trace is truncated as it usually is by
default:

Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert  
NULL
value into column 'id', table 'table'; column does not allow nulls.  
Update

fails.

  at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
  at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
  at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown  
Source)
  at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown  
Source)
  at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown  
Source)

  at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(Unknown Source)
  at  
com.sybase.jdbc3.jdbc.SybCallableStatement.executeQuery(Unknown

Source)
  at miaJs.jdbc.JdbcFacade.executeQuery(JdbcFacade.java:977)
  ... 14 more

Instead of  the "... 14 more" at the bottom, I would like to see the
entire stack trace.  I know how to get Java to do this by using
Throwable.getStackTrace(), and then loop through the array of
StackTraceElements.  I looked in the log4j source code.  I think that
FileAppender uses the OnlyOnceErrorHandler in its super, superclass
AppenderSkeleton.  It looks like OnlyOnceErrorHandler uses LogLog.   
But, I'm

not sure how to get log4j to print the entire stack trace.

Thanks,

Bob


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Config file valid for an app, but not a webapp?

2008-04-23 Thread Matt Blackmon
Greetings,

I'd appreciate your help so I can stop beating my head against the
wall in frustration.

I'm using the apache extras jar alongside the standard log4j jar.
When loading the following configuration file in a simple test app, I
get no errors and logging works correctly.  However, when using the
same configuration file in my tomcat web app, I get the following
message:
log4j:WARN Please set a rolling policy for the RollingFileAppender
named 'ROLL'.
As you may suspect, logging does not work correctly after this error.

Any ideas on why it would work in one instance and not the other?  I'm
positive the jars are in the correct place.  The only difference I can
discern is that the webapp is loading log4j via commons-logging from
apache, and the standalone app does not.  However, the webapp does use
the same log4j.xml file as evidenced by the error message.

My sincere thanks for your time and help,

Matt

log4j.xml:
http://jakarta.apache.org/log4j/";>
 
   
   
   
   
   
   
   
  
   
   
   


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: FileAppender Truncates Stack Trace

2008-04-23 Thread Matthew Kemp
You can create your own custom object renderer that will properly render the
whole stack trace. This renderer will need to be included in the log4j
config and be available on the classpath when log4j initializes.


On Wed, Apr 23, 2008 at 3:19 PM, Robert Pepersack <
[EMAIL PROTECTED]> wrote:

> Hello,
>
> I'm using FileAppender to log to a log file.  When an exception gets
> caught and printed, the stack trace is truncated as it usually is by
> default:
>
> Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert NULL
> value into column 'id', table 'table'; column does not allow nulls. Update
> fails.
>
>at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
>at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
>at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
>at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
>at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
>at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(Unknown Source)
>at com.sybase.jdbc3.jdbc.SybCallableStatement.executeQuery(Unknown
> Source)
>at miaJs.jdbc.JdbcFacade.executeQuery(JdbcFacade.java:977)
>... 14 more
>
> Instead of  the "... 14 more" at the bottom, I would like to see the
> entire stack trace.  I know how to get Java to do this by using
> Throwable.getStackTrace(), and then loop through the array of
> StackTraceElements.  I looked in the log4j source code.  I think that
> FileAppender uses the OnlyOnceErrorHandler in its super, superclass
> AppenderSkeleton.  It looks like OnlyOnceErrorHandler uses LogLog.  But, I'm
> not sure how to get log4j to print the entire stack trace.
>
> Thanks,
>
> Bob
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


FileAppender Truncates Stack Trace

2008-04-23 Thread Robert Pepersack
Hello,

I'm using FileAppender to log to a log file.  When an exception gets caught and 
printed, the stack trace is truncated as it usually is by default:

Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert NULL value 
into column 'id', table 'table'; column does not allow nulls. Update fails.

at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybCallableStatement.executeQuery(Unknown 
Source)
at miaJs.jdbc.JdbcFacade.executeQuery(JdbcFacade.java:977)
... 14 more

Instead of  the "... 14 more" at the bottom, I would like to see the entire 
stack trace.  I know how to get Java to do this by using 
Throwable.getStackTrace(), and then loop through the array of 
StackTraceElements.  I looked in the log4j source code.  I think that 
FileAppender uses the OnlyOnceErrorHandler in its super, superclass 
AppenderSkeleton.  It looks like OnlyOnceErrorHandler uses LogLog.  But, I'm 
not sure how to get log4j to print the entire stack trace.

Thanks,

Bob


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Websphere log4j configuration

2008-04-23 Thread Jacob Kjome




On Mon, 21 Apr 2008 18:04:58 -0700
 "Himanshu Shah" <[EMAIL PROTECTED]> wrote:

I have .ear application deployed in websphere. It has two war, one ejb and
one rar modules. I set the -Dlog4j.configuration=path to log4j.xml file as
JVM argument. In websphere my application class loading policy is set to:

  - Classloader order: Classes loaded with application class loader
  first
  - WAR class loader policy: Single class loader for application

I have my custom layout class which extends log4j's layout. I have
implemented getHeader() method which returns information such as product
name, version, host name etc. My problem is during websphere and application
startup header gets printed twice in log files (log messages are ok, they
are not printed twice). After debugging it looks like log4j is initialized
twice during each "war" loading.



That's curious.  I would expect log messages to be duplicates as well if 
configuration was performed twice?



Is this possible? Or is it something else?
P.S. log4j.jar resides in my application's .ear file.



Does any code in your app (or 3rd party apps) manually call configure()?  Of 
course, that wouldn't expalin by there's not duplicate log messages.


Jake


--
Himanshu
-
Fill the brain with high thoughts, highest ideals, place them day and night
before you, and out of that will come great work.
-



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Loading log4j.properties from jar file?

2008-04-23 Thread Jacob Kjome


On Wed, 23 Apr 2008 05:13:27 -0700 (PDT)
 AbelMacAdam <[EMAIL PROTECTED]> wrote:


Hi,

Today I found out the log4j.properties file my program was using was the one
in the same directory as the jar file of the program. And I was hoping to
use the log4j.properties file contained in the jar file.

When I jar my application I use:
jar cfm myapp.jar Manifest.txt nl log4j.properties HelpWindow.html
images\*.PNG

When I start the program I use
java -Dlog4j.configuration=file:log4j.properties -jar myapp.jar

And with this command I use the external properties file.

So what command do I need to use to use the internal properties file?



The following should work...

java -Dlog4j.configuration=jar:file:myapp.jar!/log4j.properties -jar myapp.jar


Jake


Abel
--
View this message in context: 
http://www.nabble.com/Loading-log4j.properties-from-jar-file--tp16834461p16834461.html

Sent from the Log4j - Users mailing list archive at Nabble.com.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LogMananger.repositorySelector was null

2008-04-23 Thread Curt Arnold


On Apr 23, 2008, at 9:59 AM, hezjing wrote:


Hi

My web-based application is using log4j release 1.2.15 and running on
Tomcat 5.5 (as a Windows service).
When I stopped the Tomcat service, the following error is printed in
stdout_20080423.log

  log4j:ERROR LogMananger.repositorySelector was null likely due to
error in class reloading, using NOPLoggerRepository.


What does this means?



Certain versions of Tomcat with certain configurations can leave log4j  
in a corrupted state that is unreachable by normal language means as  
the Tomcat classloader will set to null private static members in  
order to prevent a class of memory leaks.  It would be fine if that  
only occurred after the class was no longer used, but in some poorly  
defined instances, log4j will still be referenced after the Tomcat  
classloader plays with it.  The error indicates that a log request was  
attempted after Tomcat played with it.  Prior to log4j 1.2.15, that  
would result in a NullPointerException.  In log4j 1.2.15 and later, it  
results in this error message and all subsequent logging requests are  
discarded.  If this happens only on shutdown, you may not have missed  
anything.


For more background than you probably want, see the Tomcat and log4j  
bugs:


http://issues.apache.org/bugzilla/show_bug.cgi?id=41939
http://issues.apache.org/bugzilla/show_bug.cgi?id=40212
http://issues.apache.org/bugzilla/show_bug.cgi?id=43867


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Appender configuration question

2008-04-23 Thread Jacob Kjome

On Tue, 22 Apr 2008 16:27:52 -0400
 NBW <[EMAIL PROTECTED]> wrote:

I have a situation where I have my application JAR file which includes a 3rd
party library JAR. This 3rd party library jar includes a log4j.xml file
which configures some file appenders. 


Please contact the 3rd party and castigate them for being a bad citizen. 
Configuration is the end-user's concern, not the library writer's concern. 
They should not be supplying their own configuration.



My application's main class contains a
static Logger and its main method uses BasicConfigurator.configure(). 


So, all you want to basic Console logging with the root logger set to DEBUG?


What I
am noticing is that my application log output and log output from the 3rd
party JAR are logging to BOTH the console and to the files specified in the
3rd party JARs log4j.xml file. 


You are experiencing the additive nature of Log4j's configuration.  Every time 
configure() is called, the configuration defined either programmatically or 
via config file will be added to the existing Logger Repository configuration.



I want everything to only log to the
appenders my application specifies (namely the console). Can someone give me
some advice on doing this? Thanks.


You've got a couple optionsok three options.

1.  Continue to call BasicConfigurator.configure(), but also provide 
-Dlog4j.defaultInitOverride=true on the command line at program startup.


2.  Don't call BasicConfigurator.configure() and provide either log4j config 
file in either Properties or XML format by passing the location to it on the 
command line using -Dlog4j.configuration=myconfig.conf (can't remember if this 
needs to be a basic file path or a properly formatted file: URL???).


2.  Don't call BasicConfigurator.configure() and provide your own log4j.xml 
file (for auto-configuration, you must use log4j.xml instead of 
log4j.properties or else the 3rd party's log4j.xml will be used in preference 
to log4j.properties even if the latter is first in the classpath) and make 
sure the directory in which the file exists is placed in the classpath before 
your 3rd party jar.



Jake


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



LogMananger.repositorySelector was null

2008-04-23 Thread hezjing
Hi

My web-based application is using log4j release 1.2.15 and running on
Tomcat 5.5 (as a Windows service).
When I stopped the Tomcat service, the following error is printed in
stdout_20080423.log

   log4j:ERROR LogMananger.repositorySelector was null likely due to
error in class reloading, using NOPLoggerRepository.


What does this means?


-- 

Hez

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Appender configuration question

2008-04-23 Thread Bender Heri
First: 
It is not recommended to include the log4j.xml into a jar file, especially not 
for third party library. Therefore the best way to solve your problem is either 
to remove the file from the jar or - even better - ask the vendor of the 
library to do that.

If both is not possible, then you can try following:
- manipulate the class path in order that your log4j.xml is found before the 
one of the other library
- your own code should accesses the log4j framework before the library does, 
i.e. within a static initializer of your main class.

Heri

> -Original Message-
> From: NBW [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 22, 2008 10:28 PM
> To: log4j-user@logging.apache.org
> Subject: Appender configuration question
> 
> 
> I have a situation where I have my application JAR file which 
> includes a 3rd
> party library JAR. This 3rd party library jar includes a 
> log4j.xml file
> which configures some file appenders. My application's main 
> class contains a
> static Logger and its main method uses 
> BasicConfigurator.configure(). What I
> am noticing is that my application log output and log output 
> from the 3rd
> party JAR are logging to BOTH the console and to the files 
> specified in the
> 3rd party JARs log4j.xml file. I want everything to only log to the
> appenders my application specifies (namely the console). Can 
> someone give me
> some advice on doing this? Thanks.
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Loading log4j.properties from jar file?

2008-04-23 Thread AbelMacAdam

Hi,

Today I found out the log4j.properties file my program was using was the one
in the same directory as the jar file of the program. And I was hoping to
use the log4j.properties file contained in the jar file.

When I jar my application I use:
jar cfm myapp.jar Manifest.txt nl log4j.properties HelpWindow.html
images\*.PNG

When I start the program I use
java -Dlog4j.configuration=file:log4j.properties -jar myapp.jar

And with this command I use the external properties file.

So what command do I need to use to use the internal properties file?

Abel
-- 
View this message in context: 
http://www.nabble.com/Loading-log4j.properties-from-jar-file--tp16834461p16834461.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]