cancel
Showing results for 
Search instead for 
Did you mean: 

Application Log file

Former Member
0 Kudos

Hi Team,

I need to debugg a application and want to find the log file for this application.

I have checked the default trace file but want log specific to the application.

In the application project, there is property file for Log4j...

Refer the below contents of property file:

  1. Levels: DEBUG INFO WARN ERROR FATAL

  1. A1 is set to be a FileAppender.

log4j.appender.A1=org.apache.log4j.FileAppender

log4j.appender.A1.Threshold=DEBUG

log4j.appender.A1.File=/tmp/AppLog.log

log4j.appender.A1.layout=org.apache.log4j.PatternLayout

log4j.appender.A1.layout.ConversionPattern=\

[%p] %d{yyyy-MM-dd HH:mm:ss,SSS}%n\

%l%n\

%m%n%n

  1. Loggers configuration

log4j.logger.org.apache.struts=ERROR

log4j.logger.com.client.cip=DEBUG, A1

Can anyone help me to find the application log file from the server. Please provide the path or location.

regards

amit bagati

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member192152
Active Participant
0 Kudos

Hi Amit,

First you must set up a category for logs of its application, as shown in this blog: [WebDynpro Java log configuration|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/19623] [original link is broken];

Then use the variable logger, which is always declared within each class WebDynpro (Controller, View, ...) to define a path and name for the trace file to be used.


private static final com.sap.tc.logging.Location logger = com.sap.tc.logging.Location.getLocation(CstCtrlLibera.class);

private static Location _trace = logger;

_trace.addLog(new FileLog("./log/wdj~xyz.com~sol~portal~xyzapp.trc", "UTF-8", 1000000, 1, new TraceFormatter("%24d %l %m")));

and the logger Category:


private static final com.sap.tc.logging.Category _logger = com.sap.tc.logging.Category.getCategory(Category.APPLICATIONS, "/Portal/XYZApp");

Create a method that returns the resource (class / method) to be used:


	private static void loadResource(Exception pEx) {
		Exception ex;
		if (pEx != null) {
			ex = pEx;
		} else {
			ex = new Exception();
		}

		if (ex.getStackTrace() == null || ex.getStackTrace().length < 2) {
			return;
		}

		_className = ex.getStackTrace()[1].getClassName();
		_method = ex.getStackTrace()[1].getMethodName();
		_line = "[" + ex.getStackTrace()[1].getLineNumber() + "]";

		_resource = " - " + _user + " - " + _method + _line;
	}

And use the two variables created (_logger / _trace) in conjunction with this method in order to hold logs and traces:


	public void infoT(String message) {
		_trace.infoT(getResource(), message);
		_logger.infoT(_trace, message);
	}
	public void warningT(String message) {
		_trace.warningT(getResource(), message);
		_logger.warningT(_trace, message);
	}
	public void fatalT(String message) {
		_trace.fatalT(getResource(), message);
		_logger.fatalT(_trace, message);
	}
	public void debugT(String message) {
		_trace.debugT(getResource(), message);
		_logger.infoT(_trace, "[DEBUG]: " + message);
	}

regards,

Angelo

Edited by: Angelo Antonello Borges on Jul 5, 2010 2:35 PM

Former Member
0 Kudos

First, you're on the wrong forum. This looks like it's configured to log for a Struts application -- your question belongs in the general Java programming SCN forum. This one is for Web DynPro only, which is probably why all the other replies are a bit confused.

Your log4j settings will not write to the standard application server log -- they're configured to use a FileAppender. So, the <drive>:\usr\sap\J2E\JC00\j2ee\cluster\server0\log path is not correct. Your application appears to be logging to a file called /tmp/AppLog.log

What operating system are you using? /tmp is an absolute Unix/Linux path. If you're using Windows, your application probably isn't logging at all. You can change the location of the log by changing the property value log4j.appender.A1.File in your properties file. You could, for instance, change the line to: log4j.appender.A1.File=C:/logs/MyLog.log -- then the application would log to C:\logs\MyLog.log. (Note the forward slashes in the path -- I'm not sure if log4j escapes backslashes in its properties files correctly, so don't use those, just in case.) Make sure that the user your application server is running under has access to write to and create files in whatever directory you specify.

(As an aside, you might consider writing a custom Log4j appender to interface better with the NW AS logging system. Just a thought.)

p330068
Active Contributor
0 Kudos

Hi Amit,

Please have a loot at below document:-

/people/jacek.wozniczak/blog/2010/02/05/logging-in-web-dynpro-java--a-guide-and-tutorial-for-beginners-part-1

http://wiki.sdn.sap.com/wiki/display/WDJava/LoggingandTracinginWeb+Dynpro

You can check the log direcly if you have administrator access:-

http:/<HOST>:<PORT>/irj/servlet/prt/portal/prtroot/com.sap.portal.runtime.admin.logviewer.default

OR check in the NWA.

Hope it will helps

Regards

Arun

Former Member
0 Kudos

Hi Amit,

Go to <drive>:\usr\sap\J2E\JC00\j2ee\cluster\server0\log

Thanks and Regards,

Shyam.