Skip to Content
author's profile photo Former Member
Former Member

How to log to a file using the log-configuration.xml?

Hello *,

I created following log-configuration.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE log-configuration SYSTEM "log-configuration.dtd">

<log-configuration>

<log-formatters>

<log-formatter name="DefaultFormatter" pattern="%25d %-60l %s: %m" type="TraceFormatter"/>

</log-formatters>

<log-destinations>

<log-destination count="10" effective-severity="ALL" limit="1000000" name="DefaultDestination" pattern="FDLB_GUI.%g.trc" type="FileLog">

<formatter-ref name="DefaultFormatter"/>

</log-destination>

</log-destinations>

<log-controllers>

<log-controller effective-severity="ALL" maximum-severity="FATAL" minimum-severity="DEBUG" name="DefaultController">

<associated-destinations>

<destination-ref association-type="LOG" name="DefaultDestination"/>

</associated-destinations>

</log-controller>

</log-controllers>

</log-configuration>

From a Web Dynpro view I want to use the log-controller. I'm using the default logger:

/**

  • Logging location.

*/

private static final com.sap.tc.logging.Location logger =

com.sap.tc.logging.Location.getLocation(EinstiegView.class);

In the wdInit method I want to log a simple message:

public void wdDoInit()

{

//@@begin wdDoInit()

logger.setEffectiveSeverity(com.sap.tc.logging.Severity.ALL);

logger.fatalT("test logging to new file logger");

//@@end wdDoInit()

}

I see the message in the defaultTrace.0.log, but my own log file doesn't appear.

How to address the log-controller of my log-configuration.xml?

Thanks in advance,

Jürgen Dufner

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2004 at 10:29 AM

    You can use FileLog for writing messages to specific files.

    Use the following API for specifying the destination:

    Syntax: logger.addLog(<log1>);

    The simplest ways to do so is as below:

    logger.addLog(new FileLog(“C:
    temp
    <filename>.log”); // filepath has to be valid.

    Note that the file path can be relative also. This helps, as the code then becomes portable.

    loc.addLog(new FileLog("
    usr
    sap
    Output1.log", new TraceFormatter()));

    Hope it helps!

    Regards,

    Vishnu Prasad Hegde

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Vishnu,

      thanks, I know how configure a logger in dynamically in a Java class.

      But I want know how to use a logger which is configures in a log-configuration.xml

      Regards,

      Jürgen Dufner

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2004 at 12:23 PM

    Hi,

    we had the same 'problem'.

    We switched the flag 'FrorceSingleTraceFile' off in the ConfigTool and that did the trick.

    In an earlier posting someone mentioned that there is meanwhile an oss note on this issue.

    Regards, Astrid

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I guess the follwing part of your log-configuration is wrong:

      <log-controller

      effective-severity="ALL"

      maximum-severity="FATAL" m

      nimum-severity="DEBUG"

      name="DefaultController">

      .....

      Try to change in log-configuration the value for name in <log-controller> to the start sequence of the packages to be logged. E.g., all our packages should start with com.yourcompanyname.projectname

      To log all messages from classes in these packages make the name = com.yourcompanyname.projectname.

      Hope that helps,

      Regards, Astrid

      Therefore I list

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2004 at 01:10 PM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.