cancel
Showing results for 
Search instead for 
Did you mean: 

How to use logging in the actions classes extends standart actions?

former_member186148
Active Participant
0 Kudos

Hello!

I have some action classes extends standart actions, for example Z_ExtMaintainBasketDispatcherAction extends MaintainBasketDispatcherAction. I tried to use logging functionality in my classes but there were no my lines in log and trace files.

For example I added followed lines in basketPerform() method of Z_ExtMaintainBasketDispatcherAction:

boolean isDebugEnabled = log.isDebugEnabled();
if(isDebugEnabled){
log.debug("++++++++++++++++ Test tracing in B2B_SNG. ++++++++++++++++");
}

...

but in there was no such line neither in log file nor in trace file.

How I can use logging functionality in my own classes? I need it for tracing and logging.

CRM 5.0

regards, Lev

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

 private static final IsaLocation log = IsaLocation.getInstance(ClassName.class.getName());
    // simple developer trace
    log.debug("This is a trace message");
    // entering exiting method
    log.entering("myMethod()");
    log.exiting();
    // Tracing when throwing exception for dev/support. PATH is internally used as severity.
    // No stacktrace is printed
    log.throwing(ex);
    // with some additional information
    log.throwing("exception trace for support", ex);
    // catching exception. Trace only if relevant for support
    log.error("isatest.error.exception", ex);

Must intialize the location first.

Reference: Extension Guide - Section - Logging and Tracing.

former_member186148
Active Participant
0 Kudos

Hello!

Thank you for answer. I've read this section in Dev. Guide. But there is a little confusion: variable "log" is an input parameter of basketPerform() method so I can't declare it as member of my class. Or should I declare another variable named myLog in my class, initialize it like this:

private static final IsaLocation myLog = IsaLocation.getInstance(ClassName.class.getName());

and use it instead of "log"?

regards, Lev

Former Member
0 Kudos

I think so.

former_member186148
Active Participant
0 Kudos

No effect...

I've got a

private static final IsaLocation myLog = IsaLocation.getInstance(Z_ExtMaintainBasketDispatcherAction.class.getName());

but

myLog.isDebugEnabled()

returns false

Edited by: Lev Kulaev on Jun 5, 2009 11:03 AM

Edited by: Lev Kulaev on Jun 5, 2009 11:04 AM

Former Member
0 Kudos

Did you try with ........... myLog = .........."ClassName.class.getName()"?

former_member186148
Active Participant
0 Kudos

Yes.

I declared variable "myLog" like this:

private static final IsaLocation myLog = IsaLocation.getInstance(Z_ExtMaintainBasketDispatcherAction.class.getName());

but in basketPerform() method code

boolean isDebugEnabled = myLog.isDebugEnabled();
if(isDebugEnabled){
	myLog.debug("++++++++++++++++ Test tracing in B2B_SNG. ++++++++++++++++");
}

still doesn't worked since myLog.isDebugEnabled() returns false;

I use it with myLog.isDebugEnabled() since I want to see this debug statement in log file only in session tracing mode.

Former Member
0 Kudos

Do you have to declare that your class is eligible for logging in the log-config properties file in the WEB-ING/cfg folder?.

Answers (2)

Answers (2)

former_member186148
Active Participant
0 Kudos

Well, here is solution. I created a log formatter and log destination like this:

<log-formatters>
<log-formatter name="application_sap.com/crm~b2b" type="TraceFormatter" pattern="%d,%-3p %t %s %l %m"/>
</log-formatters>
<log-destinations>
<log-destination name="application_sap.com_crm.b2b" type="FileLog"
    count="10" effective-severity="ALL" limit="10000000" pattern=".\log\applications\isa_ru.log">
<formatter-ref name="application_sap.com/crm~b2b"/>
</log-destination>
</log-destinations>

and new log controller like this:

<log-controller effective-severity="ALL" name="ru.sng.isa">
<associated-destinations>
<destination-ref name="application_sap.com_crm.b2b" association-type="LOG"/>
</associated-destinations>
</log-controller>

in file META-INF\log-configuration.xml

Thanks everybody for help!

Regards, Lev.

Former Member
0 Kudos

You need to enable the log first.You can set the log levels from here itself.

Please use Visual Administrator of J2EE Engine => Server => Services

=> Log Configurator logging configuration