cancel
Showing results for 
Search instead for 
Did you mean: 

How to use application logger ?

Former Member
0 Kudos

Hi,

I have created a JSPDynPage application that I've deploy ion my portal (EP6 SP13)

I want to use logger to manage it.

For this, I've read many documentation but I can not find 2 documentations which are saying the same thing...

Actually:

/* I created a location in each class */

private static final Location LOCATION = Location.getLocation(MyClass.class);

/* I reference the application category */

private static final Category CATEGORY = Category.getCategory(Category.APPLICATIONS, Constants.APPLICATION_NAME);

/* And I use this as: */

CATEGORY.infoT(LOCATION, "doInitialization", "User logged in", new Object[] { m_timeManagment.getFirstName()}); /* And: */ LOCATION.infoT("doInitialization", "User started transaction", new Object[] { m_timeManagment.getFirstName()});

But I think I must do other think ...

Like for example create a log-configuration.xml file in my application folder (under "logger" repository?)

Should I reference it in the portalapps.xml ?

...

Can someone tell me exactly how to do, please ?

Thanks,

Fabien

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member185837
Active Participant
0 Kudos

And if you preferred, Fabien, the <u>com.sap.tc.logging</u> API to the EP's <u>com.sapportals.portal.prt.logger</u> API, then you could use it in your code (just as you currently do), and <b>manually</b> define the corresponding location/category inside the Log Configurator Service of the J2EE Engine. As Detlev said, in fact, the log-configuration.xml file is useful just for J2EE applications.

So if your application super-package is, for instance, com.company.yourapplication, you could add a new location under <i>Log Configurator -> Locations -> com</i>, with name com.company.yourapplication, set its desired level, and save.

Davide

Former Member
0 Kudos

Hello Davide,

I understand your solution ...

I am not a log user friendly but it seems that one has its advantage ...

On the one hand, we have the definitino of logger in the application but we lose log efficient useing old API.

On the other hand, we use new API and all its functionnalities but logger deinition is independant of the application itself ...

For you, what is the best solution ?

Thanks,

Fabien

former_member185837
Active Participant
0 Kudos

Well, this is exactly the point. I could say that, from a developer's perspective, the new API solution is better, because you can get a finer tracing of your code with it.

On the other hand, from an administrator's one, it's easier to deploy a PAR and have the logging functionality automatically configured.

Anyway, have you tried to include both the <u>is active</u> and <u>level</u> parameters in the logger description? Is it true that, in this case, the location severity is automatically set to the chosen level, as written in the doc?

<i>The location severity now depends on two parameters: „is active“ and „level“. Only if the parameter is set to „is active“ (true) can the location severity be defined with parameter „level“. If „is active“ is not true, the location severity is not defined („None“).</i>

Personally I've never tested this, so I have always had to configure the severity manually. If this worked, than the old way would be a real advantage for the admin. If it didn't work, there would be a further argument for choosing the new approach.

Davide

detlev_beutner
Active Contributor
0 Kudos

Hi Fabien,

> what is the best solution ?

As you've said, both have serious (dis)advantages. So - it depends...

But another thought on this:

It is possible to put a PAR into an EAR, see http://help.sap.com/saphelp_erp2004/helpdata/en/76/27044017355c0ce10000000a1550b0/frameset.htm and and the sap note mentioned there.

All SAP would have to do is to extend the "Add Module" functionality also to have the possibility to add portal project / PAR as module. With that, you could deploy a logging configuration with the EAR together with the PAR!

Dreaming...

Best regards

Detlev

former_member185837
Active Participant
0 Kudos

<i>The location severity now depends on two parameters: „is active“ and „level“. Only if the parameter is set to „is active“ (true) can the location severity be defined with parameter „level“. If „is active“ is not true, the location severity is not defined („None“).</i>

I tested this but I couldn't activate the location severity. I tried to set the attributes <u>isActive="true"</u> and <u>level="ALL"</u> in the <u><Logger></u> element, in the <u><LoggerClass></u> element, in both, however in neither case the severity was automatically assigned to the newly created location. It was always NONE and I had to manually set it inside the Log Configurator Service.

Having the admin to carry on some configuration after deployment, I can't see any dramatic advantage in using logger.xml rather than using the new API and instruct (in the documentation) the administrator to manually create the location.

Davide

Former Member
0 Kudos

Hi Detlev,

I've created a Portal application and put a logger.xml file to manage logs.

But I do not manage to see log in the LogViewer, so I think that something is wrong in my code or my configuration.

Usually, the location (com.sap.com.myLogger where myLogger is thename of the logger in the logger.xml file) is created when I <u>deploy</u> the application on the server, right ?

My logger.xml is in the PORTAL-INF/logger.

It is:

<Server>

<Logger name="fabcouLog" loggerInterface="com.sapportals.portal.prt.logger.ILogger" locationName="com.sap.portal.timeManagment" pattern="%d # %20t %15s %m #" isActive="true">

<LoggerClass className="com.sapportals.portal.prt.logger.SimpleFileLogger" level="DEBUG">

<param filename="logs/fabcouLog.log" append="true"> </param>

</LoggerClass>

</Logger>

</Server>

And when I go to the log configurator, I do not see any new location : com.sap.portal.fabcouLog

Have you any idea?

PS: I can send you my code if you want to test it on your server ..

Thanks a lot,

Fabien

Former Member
0 Kudos

Hi Detlev,

Do not take care of my last message.

I've found my problem ...

Thanks,

Fabien

Former Member
0 Kudos

Hi Davide,

<i>The location severity now depends on two parameters: „is active“ and „level“. Only if the parameter is set to „is active“ (true) can the location severity be defined with parameter „level“. If „is active“ is not true, the location severity is not defined („None“).</i>

I try to put a logger.xml file with the <b>isActive="true"</b> attribute in the Logger tag and the <b>level="DEBUG"</b> attribute in the LoggerClass tag.

And this creates a new location in the logViewer with the level "ALL" ... (not NONE)

Thanks,

Fabien

Former Member
0 Kudos

Hi Detlev,

Using ILogger and logger.xml file, you can only use INFO, SEVERE and WARNING ....?

You can not use DEBUG mode ?

Because in the java api ILogger dos not have this method ...

Right ?

Thanks,

Fabien

Former Member
0 Kudos

Hi,

Using logger.xml, <b>All</b> trace are written into defaultTrace.trc ???

You can not choose a output file ?

Regards,

Fabien

former_member185837
Active Participant
0 Kudos

Fabien, I couldn't reproduce that on my system. Could you please post your logger.xml file? This is mine. Do you notice something different?

<Server>
<Logger name = "it.trilog.test" loggerInterface = "com.sapportals.portal.prt.logger.ILogger" isActive = "true">
	<LoggerClass className = "com.sapportals.portal.prt.logger.SimpleFileLogger" level = "DEBUG"/>
</Logger>
</Server>

Thanks, Davide

former_member185837
Active Participant
0 Kudos

Hava a look at:

Cheers, Davide

former_member185837
Active Participant
0 Kudos

<i>Using ILogger and logger.xml file, you can only use INFO, SEVERE and WARNING ....?

You can not use DEBUG mode ?</i>

This is one reason why I prefer <u>com.sap.tc.logging.Location</u>.

Cheers, Davide

Former Member
0 Kudos

Hi Davide,

I've tried your logger file descripiton, and this create a location under: sap.com.portal.it.trilog.test with level=ALL.

Same thing as mine ...

My logger is the followings:

<Server>

<Logger name="testLog" loggerInterface="com.sapportals.portal.prt.logger.ILogger" locationName="com.sap.portal.testLog" pattern="%d # %20t %15s %m #" isActive="true">

<LoggerClass className="com.sapportals.portal.prt.logger.SimpleFileLogger" level="INFO">

<param filename="logs/fabcouLog.log" append="true">

</param>

</LoggerClass>

</Logger>

</Server>

Regards,

Fabien

former_member185837
Active Participant
0 Kudos

Mystery of version levels.... Mine are:

J2EE Engine 6.40 PatchLevel 89291.313 
Portal 6.0.11.3.0

Thank you, Davide

detlev_beutner
Active Contributor
0 Kudos

Hi Fabien,

about the open questions:

> Using ILogger and logger.xml file,

> you can only use INFO, SEVERE and WARNING ....?

... plus ALL, OFF, and SYSTEM, see https://media.sdn.sap.com/javadocs/NW04/SP12/runtime/com/sapportals/portal/prt/logger/Level.html for details.

> Using logger.xml, All trace

> are written into defaultTrace.trc ???

Only if central logging is activated (but then, also the other logs are logged into the defaultTrc).

> this create a location under:

> sap.com.portal.it.trilog.test

See http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm for details how the logger name is transferred into the log configuration.

Hope it helps

Detlev

former_member185837
Active Participant
0 Kudos

Hi Detlev,

> > this create a location under:

> > sap.com.portal.it.trilog.test

> See

> http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm

> for details how the logger name is transferred into

> the log configuration.

Yes, I have no problem with the logger name transferring into the log config. However I can't set the logger's <b>level</b> in the logger.xml file, although Fabien can (we both tried with the same file).

Thanks, Davide

Former Member
0 Kudos

Fabien

This is probably a naive question but have you looked at whether "INFO" logging will work on your system. I know with the system default log levels can be turned off ie on our sytem INFO and warning are off so logs don't post.

I don't know about the Application log though. I want to learn how to use it myself so very interested in the final solution.

Liz

Former Member
0 Kudos

Hi Liz,

I've tried to use the "ALL" level to avoid this kind of restriction but it does not work too.

During you search, if you found solutions to the use of log, I will be interesting on.

On my part, I will send you solution if I found one ...

Regards,

Fabien

detlev_beutner
Active Contributor
0 Kudos

Hi Fabien,

the log-configuration.xml works only on J2EE applications (and now you know the difference ); within the portal you can use the older logger.xml.

See http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm for details.

Hope it helps

Detlev

Former Member
0 Kudos

Hi,

I've created a new Enterprise Application Projet into which I put a Web Module project (Standar J2EE application).

In myEnterprise Application Projet, I've added a log-configuration.xml file.

But when I deploy the .ear into the SAP J2EE Engine, nothing happen: I can not see the new Location and Category in the visual Administrator.

When are they created? When Deployment? After ?

Thanks,

Fabien

Thanks,

Fabien

Former Member
0 Kudos

Hi,

I have a problem with the definition and the use of log-configuration.xml file.

Here, I use the log-configuration.xml file...

But the code seems OK but I don't see any log or location/category in the Log viewer

My log-configuration.xml is:

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

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

<log-configuration>

<log-formatters>

<log-formatter

name="DefaultFormatter"

pattern="%24d %l [%s]: %m"

type="TraceFormatter"/>

</log-formatters>

<log-destinations>

<log-destination

count="10"

effective-severity="INFO"

limit="1000000"

name="application_log"

pattern="./log/applications/TimeManagmentWithLog/defaultTrace.%g.trc"

type="FileLog">

<formatter-ref name="DefaultFormatter"/>

</log-destination>

</log-destinations>

<log-controllers>

<log-controller

effective-severity="INFO"

name="com.eurocopter.portal.time.management.process">

<associated-destinations>

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

</associated-destinations>

</log-controller>

<log-controller

effective-severity="INFO"

name="/Application/TimeManagmentWithLog">

<associated-destinations>

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

</associated-destinations>

</log-controller>

</log-controllers>

</log-configuration>

So, I define a location: com.eurocopter.portal.time.management.process

And a category: /Application/TimeManagmentWithLog

And the destination of the log file: ./log/applications/TimeManagmentWithLog/defaultTrace.%g.trc

And in the java code, I use:

package com.eurocopter.portal.time.management.process;

...

private static final Location LOCATION = Location.getLocation(TimeManagementProcess.class);

private static final Category CATEGORY = Category.getCategory(Category.APPLICATIONS, Constants.APPLICATION_NAME);

...

CATEGORY.infoT(LOCATION, "doInitialization", "User logged in", new Object[] { m_timeManagment.getFirstName()}); LOCATION.infoT("doInitialization", "User started transaction", new Object[] { m_timeManagment.getFirstName()});

I would thinking this creates the logfile in the sepcified destination and that I can see the category and the location in log Configurator..

But nothing happens...

Did I do something wrong ?

Thanks,

Fabien

Former Member
0 Kudos

Hi,

I give more information...

I add a log-configuration.xml file into my application.

I put it in the dist/PORTAL-INF/logger directory of my application.

And I write a log-formatter,log-destination and log-controller as said in the "http://help.sap.com/saphelp_nw04/helpdata/en/5f/e5de3f68d48f15e10000000a155106/frameset.htm" documentation

Do I have to define this log file (log-configuration.xml) in the portalapp.xml definition file ?

How can I use log defined into log-configuration.xml in my java code ?

Thanks,

Fabien

Former Member
0 Kudos

Ping me @ sapmails(at)gmail.com .I wud send U a gud doc on Logging.

Regards.

Former Member
0 Kudos

Hi Peter,

OK, I send you a mail to sapmails@gmail.com ...

Thanks for your documentation ...

Fabien

Former Member
0 Kudos

Sent!

Regards