cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
jrgen_bechtle
Participant
0 Kudos

isn't working anymore...

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello Astrid,

where do I have to turn off 'ForceSingleTraceFile'?

In the global or instance configuration and / or in the server or the dispatcher?

Thanks a lot,

Jürgen Dufner

Former Member
0 Kudos

In config tool :

/usr/sap/J2E/JC00/j2ee/configtool/configtool.bat

Launch that application.

In the tab:

cluster-data -> Global server configuration -> managers ->

LogManager

Set ForceSingleTraceFile custom value to NO

Former Member
0 Kudos

Of course, then restart your J2EE engine

Former Member
0 Kudos

Hello Alexis,

I turned 'ForceSingleTraceFile' to NO. But the Application Server doesn't created my Log file. Could you please take a look to my configuration and my source code earlier in the thread.

Thanks,

Jürgen

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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