You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by jin xin <jx...@hotmail.com> on 2006/12/19 04:25:23 UTC

quesiton about LoggingEvent

Hi:

I use the following code

Class testClass
{

public void test1()
{
---
Throwable throwable = null;
Throwable child = new Throwable("test");
LoggingEvent loggingEvent = new 
LoggingEvent(this.getClass().getName(),testLogger,Level.DEBUG,logMsg,child);
System.out.println("class = 
"+loggingEvent.getLocationInformation().getClassName());
System.out.println("method = 
"+loggingEvent.getLocationInformation().getMethodName());
System.out.println("line = 
"+loggingEvent.getLocationInformation().getLineNumber());---
---}
}
I am expecting to see the className, methodName and lineNumber to print out, 
however, I only get "?" for classNamem methodName and lineNumber.

Can anybody advise me what I did wrong?

Thanks

_________________________________________________________________
Off to school, going on a trip, or moving? Windows Live (MSN) Messenger lets 
you stay in touch with friends and family wherever you go. Click here to 
find out how to sign up!  http://www.telusmobility.com/msnxbox/


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


Log4j prob with jboss

Posted by "Parmar, Vijendra Singh" <Vi...@ca.com>.
I played with log4j upto a great extent. My required output was supposed
to be my own logging mechanism in which i should be able to create
userlog.log name kind of different file and logs should generate in
specific format(name#action#parameter) so that i can read the data
easily. I am able to do in some jboss locations as i am testing in many
servers before deploying. By modifying in log4j.xml based on
appenders(File/Console).But in my local system i am unable to test it as
here file appender is not working. I get a black log file but things get
logged in server.log here i can't get selective data in selective
format. I don't know, i am missing any configuration or jboss server is
having any problem or log4j.jar is having prob. For this i replaced many
log4j.jar one by one and even set the classpath accordingly.But no
benefit. Can anyone guide me what can be the cause of this. Now taking a
look at jboss-service.xml also.

 Vijendra

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


Re: quesiton about LoggingEvent

Posted by Curt Arnold <ca...@apache.org>.
On Dec 18, 2006, at 9:25 PM, jin xin wrote:

> Hi:
>
> I use the following code
>
> Class testClass
> {
>
> public void test1()
> {
> ---
> Throwable throwable = null;
> Throwable child = new Throwable("test");
> LoggingEvent loggingEvent = new LoggingEvent(this.getClass().getName 
> (),testLogger,Level.DEBUG,logMsg,child);
> System.out.println("class = "+loggingEvent.getLocationInformation 
> ().getClassName());
> System.out.println("method = "+loggingEvent.getLocationInformation 
> ().getMethodName());
> System.out.println("line = "+loggingEvent.getLocationInformation 
> ().getLineNumber());---
> ---}
> }
> I am expecting to see the className, methodName and lineNumber to  
> print out, however, I only get "?" for classNamem methodName and  
> lineNumber.
>
> Can anybody advise me what I did wrong?
>
> Thanks

I see two potential usage errors.  First, perhaps the caller was not  
compiled with debug information.  In this case, you likely passed the  
"testClass" as the fully qualified logger name, so the reported  
location will be the location that called testClass.test1 and the  
test framework might not have been compiled with debugging info.

The second and less likely is that you extended testClass and the  
value of this.getClass().getName() isn't "testClass" but the name of  
the extended class, but the stack trace contains "testClass.test1"  
and log4j isn't able to determine the name of the caller.  Using  
testClass.class.getName() would be better.

If you are still having problems, I'd suggest debugging into the  
getLocationInformation() call and see where things are breaking apart  
and if a resolution is not obvious, describe your observations and  
specify the version of log4j that you are using, the JVM in use,  
platform et al.




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


Re: quesiton about LoggingEvent

Posted by Jacob Kjome <ho...@visi.com>.
Did you compile with javac debug enabled?

jake

Quoting jin xin <jx...@hotmail.com>:

> Hi:
>
> I use the following code
>
> Class testClass
> {
>
> public void test1()
> {
> ---
> Throwable throwable = null;
> Throwable child = new Throwable("test");
> LoggingEvent loggingEvent = new
> LoggingEvent(this.getClass().getName(),testLogger,Level.DEBUG,logMsg,child);
> System.out.println("class =
> "+loggingEvent.getLocationInformation().getClassName());
> System.out.println("method =
> "+loggingEvent.getLocationInformation().getMethodName());
> System.out.println("line =
> "+loggingEvent.getLocationInformation().getLineNumber());---
> ---}
> }
> I am expecting to see the className, methodName and lineNumber to print out,
> however, I only get "?" for classNamem methodName and lineNumber.
>
> Can anybody advise me what I did wrong?
>
> Thanks
>
> _________________________________________________________________
> Off to school, going on a trip, or moving? Windows Live (MSN) Messenger lets
> you stay in touch with friends and family wherever you go. Click here to
> find out how to sign up!  http://www.telusmobility.com/msnxbox/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>




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