List Info

Thread: Unable to display caller name in log info




Unable to display caller name in log info
user name
2008-06-13 10:15:47
Hi,

I wrote a small Java program to configure an org.apache.log4j.Logger and log messages using it.

Excerpts from the Java file are:

package MyPackage;

//...

public class LogTest
{
    private static Hashtable cLoggerHash = new Hashtable();
    private void setLogInfo()
    {
      ;  String sLogFile = "TestLogFile.log";
       ; Logger cLogger = Logger.getLogger( sLogFile );
    ;    cLogger.setLevel( Level.toLevel("DEBUG") );
    ;    PatternLayout cLayout = new PatternLayout();
        cLayout.setConversionPattern( "[%d{yyyy/MM/dd HH:mm:ss.SSS}]%C ;    - %m%n" );
  ;
     
        RollingFileAppender cFileAppender = new RollingFileAppender();
        //...
        cFileAppender.activateOptions(
);
 ;       cFileAppender.setLayout( cLayout );
 ;       cLogger.addAppender( cFileAppender );
 ;       cLoggerHash.put( sLogFile, cLogger );
 ;  }
   public static void main (String[] args)
   {
   ;    LogTest logTest = new LogTest();
       logTest.setLogInfo();
       Logger cLogger = Logger.getLogger( "TestLogFile.log" );
 ;      cLogger.log("TestLogFile.log", Level.INFO,  "t ++++++++++++++ This is a test log +++++++++++++++++ ", null);
    ;    
   }
   ;    
The output is:
[2008/06/13 20:24:53.415]?     -     ++++++++++++++ This is a test log +++++++++++++++++


The fully qualified classname is NOT displayed.
Instead a "?" is displayed.

Please help.

Regards,
Debarshi
Re: Unable to display caller name in log info
user name
2008-06-13 11:56:14
On Jun 13, 2008, at 10:15 AM, Debarshi Sanyal wrote:

> Hi,
>
> I wrote a small Java program to configure an
org.apache.log4j.Logger  
> and log messages using it.
>
> Excerpts from the Java file are:
>
> package MyPackage;
>
> //...
>
> public class LogTest
> {
>     private static Hashtable cLoggerHash = new
Hashtable();
>     private void setLogInfo()
>     {
>         String sLogFile = "TestLogFile.log";
>         Logger cLogger = Logger.getLogger( sLogFile );
>         cLogger.setLevel(
Level.toLevel("DEBUG") );
>         PatternLayout cLayout = new PatternLayout();
>         cLayout.setConversionPattern(
"[%d{yyyy/MM/dd HH:mm:ss.SSS}] 
> %C     - %m%n" );
>
>
>         RollingFileAppender cFileAppender = new
RollingFileAppender();
>         //...
>         cFileAppender.activateOptions(
> );
>         cFileAppender.setLayout( cLayout );
>         cLogger.addAppender( cFileAppender );
>         cLoggerHash.put( sLogFile, cLogger );
>    }
>    public static void main (String[] args)
>    {
>        LogTest logTest = new LogTest();
>        logTest.setLogInfo();
>        Logger cLogger = Logger.getLogger(
"TestLogFile.log" );
>        cLogger.log("TestLogFile.log",
Level.INFO,  "t +++++++++++++ 
> + This is a test log +++++++++++++++++ ", null);
>
>    }
>
> The output is:
> [2008/06/13 20:24:53.415]?     -     ++++++++++++++
This is a test  
> log +++++++++++++++++
>
>
> The fully qualified classname is NOT displayed.
> Instead a "?" is displayed.
>
> Please help.
>
> Regards,
> Debarshi


This question should have been asked on log4j-user, not
log4cxx-user.   
The most common cause is that the class file was not
compiled with  
debug information.


Re: Unable to display caller name in log info
user name
2008-06-16 04:13:18
Sorry for posting to the wrong forum and thanks for the response. But could you please let me know if any special flags need to be turned on in javac or java.

Best Regards,
Debarshi


On 6/13/08, Curt Arnold < carnoldapache.org">carnoldapache.org> wrote:

On Jun 13, 2008, at 10:15 AM, Debarshi Sanyal wrote:

Hi,

I wrote a small Java program to configure an org.apache.log4j.Logger and log messages using it.

Excerpts from the Java file are:

package MyPackage;

//...

public class LogTest
{
   private static Hashtable cLoggerHash = new Hashtable();
   private void setLogInfo()
   {
       String sLogFile = "TestLogFile.log";
       Logger cLogger = Logger.getLogger( sLogFile );
       cLogger.setLevel( Level.toLevel("DEBUG") );
       PatternLayout cLayout = new PatternLayout();
       cLayout.setConversionPattern( "[%d{yyyy/MM/dd HH:mm:ss.SSS}]%C     - %m%n" );


       RollingFileAppender cFileAppender = new RollingFileAppender();
       //...
       cFileAppender.activateOptions(
);
       cFileAppender.setLayout( cLayout );
       cLogger.addAppender( cFileAppender );
       cLoggerHash.put( sLogFile, cLogger );
  }
  public static void main (String[] args)
  {
      LogTest logTest = new LogTest();
      logTest.setLogInfo();
      Logger cLogger = Logger.getLogger( "TestLogFile.log" );
 ;     cLogger.log("TestLogFile.log", Level.INFO,  &quot;t ++++++++++++++ This is a test log +++++++++++++++++ ", null);

  }

The output is:
[2008/06/13 20:24:53.415]?     -     ++++++++++++++ This is a test log +++++++++++++++++


The fully qualified classname is NOT displayed.
Instead a "?&quot; is displayed.

Please help.

Regards,
Debarshi


This question should have been asked on log4j-user, not log4cxx-user.  The most common cause is that the class file was not compiled with debug information.


Re: Unable to display caller name in log info
user name
2008-06-16 12:03:18
On Jun 16, 2008, at 4:13 AM, Debarshi Sanyal wrote:

> Sorry for posting to the wrong forum and thanks for the
response.  
> But could you please let me know if any special flags
need to be  
> turned on in javac or java.
>

Try adding a -g to your javac command.

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )