cancel
Showing results for 
Search instead for 
Did you mean: 

logging

Former Member
0 Kudos

Hi,

What class and method do I use to log into defaultTrace.0.trc file?

Thanks.

eng12042

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi eng12042,

If you want to use the defaultTrace.0.trc file for logging then just write the statement:

<b>System.err.println("This is the error in defaultTrace.0.trc file");</b>

Just include this line in the code. You can view the line in defaultTrace.0.trc file. Similarly you can write anything you want in this statement.

For eg:

<b>System.err.println("Value==" +value);</b>

This will print the value in the <b>defaultTrace.0.trc file</b>

I hope this solves your problem. If any more clarification required then please revert back.

Regards

Pravesh

PS: Please consider rewarding points if helpful.

detlev_beutner
Active Contributor
0 Kudos

Hi eng12042, hi Pravesh,

> just write the statement

This is not <i>logging</i>!

eng12042: Helmut showed you a short form how to use the "new" (J2EE server) logging API. The alternative is to use the older portal logging API. To get an overview, start here: http://help.sap.com/saphelp_erp2004/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm

Hope it helps

Detlev

pravesh_verma
Active Contributor
0 Kudos

Hi Detlev,

Ya I know this is not logging. Infact the way Helmut showed is by using a logger. This uses the <b>log4j</b> classes. But what eng12042 was looking for how to log in the way to log into <b>defaultTrace.0.trc file</b>.

So by using the <b>err</b> statement we can log into defaultTrace.0.trc file without any problem. This is what I thought eng12042 was asking for. If not then its a mistake from my side.

Hi eng12042,

In other case you have to use a logger or the way Detlev has suggested. You can create a logger file and put it in the logger folder in your project structure.

I hope this helps you! And thanks Detlev for correcting, if I am wrong

Regards

Pravesh

former_member441228
Active Participant
0 Kudos

Hi Pravesh, the statement that sap.tc.logging uses log4j is not correct.

Further, using the standard print streams only works if it's configured that way; fortunately, that's the shipping default nowadays.

detlev_beutner
Active Contributor
0 Kudos

Hi Pravesh,

> This uses the log4j classes.

No, that's the SAP internal loger.

> But what eng12042 was looking for how to log in the

> way to log into defaultTrace.0.trc file.

Right, and logging using the central logging installation as Helmut showed or using the old portal logger both <i>log</i> into default.trc!

> err statement we can <i>log</i> into defaultTrace.0.trc

> file without any problem

Please, again, it is not <i>logging</i> in a formal way. You can print out some text. That's something different. And even if sometimes I'm using this for a fast check - one should definitely be aware that it's a hack, that its code that has to be removed in productive code and that logging is something different.

No offense meant!

Best regards

Detlev

pravesh_verma
Active Contributor
0 Kudos

Hi Detlev, Helmut

Well thanks for updating abt log4j classes!!

I may have read incorrect document.

Anyways, I never knew that we are hacking defaultTrace.0.trc file by using a small statement.

Regards

Pravesh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi All,

Thanks a lot for your help.

<b>System.err.println</b> does the job: logging into defaultTrace.0.trc. I can also view the a log line in the logviewer for defaultTrace.0.trc.

Best regards,

eng12042

Message was edited by: eng12042 eng12042

Message was edited by: eng12042 eng12042

former_member441228
Active Participant
0 Kudos

import com.sap.tc.logging.Location;

Location loc = Location.getLocation(yourClass.class);

loc.errorT("bla");