[xwiki-users] Redirecting logs to a file instead of console on tomcat?
I have gone thru http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Logging. As per logback.xml(inside in MyApp/WEB_INF/classes), looks like it relies on the fact that container will redirect all the console to logfile automaticcaly. But it is not happening. I am using tomcat 6. i want to put all the possible logs i.e log.info.log.warn,log.error,log.debug,log.fatal inside log file For logging i am using below code snippet private static final Log log = org.apache.commons.logging.LogFactory.getLog(AuthServiceImpl.class);// declared as insiance variable under AuthServiceImpl.class then in my public method i am doing the logging as log.error("Testing AuthServiceImpl Reply = "); But its printing the logs on tomcat console. Guys really i have no idea how to print the to file instead of console.Inside logback.xml(inside in MyApp/WEB_INF/classes) i can see below setting. I have really no idea what is happening? Thanks in advance.
Now as per http://logback.qos.ch/manual/joran.html , i tried to use file Appender to log the message to file* but no help*. Here is added code snippet in logback.xml <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file> <layout class="ch.qos.logback.core.ConsoleAppendert"> <Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern> </layout> </appender> <root level="debug"> <appender-ref ref="FILE" /> </root> ---------- Forwarded message ---------- From: mohit gupta <[email protected]> Date: Thu, Apr 19, 2012 at 10:06 PM Subject: Redirecting logs to a file instead of console on tomcat? To: XWiki Users <[email protected]> I have gone thru http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Logging. As per logback.xml(inside in MyApp/WEB_INF/classes), looks like it relies on the fact that container will redirect all the console to logfile automaticcaly. But it is not happening. I am using tomcat 6. i want to put all the possible logs i.e log.info.log.warn,log.error,log.debug,log.fatal inside log file For logging i am using below code snippet private static final Log log = org.apache.commons.logging.LogFactory.getLog(AuthServiceImpl.class);// declared as insiance variable under AuthServiceImpl.class then in my public method i am doing the logging as log.error("Testing AuthServiceImpl Reply = "); But its printing the logs on tomcat console. Guys really i have no idea how to print the to file instead of console.Inside logback.xml(inside in MyApp/WEB_INF/classes) i can see below setting. I have really no idea what is happening? Thanks in advance.
On 04/19/2012 01:51 PM, mohit gupta wrote:
Now as per http://logback.qos.ch/manual/joran.html , i tried to use file Appender to log the message to file* but no help*. Here is added code snippet in logback.xml
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>myApp.log</file>
You should use an absolute file path, since this filename could end up anywhere, depending on how Tomcat was started and what it considers the "current directory". Make sure the location you provide is writable by the owner of the tomcat process.
<layout class="ch.qos.logback.core.ConsoleAppendert">
^ typo here, ConsoleAppender[t]
<Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern> </layout> </appender>
<root level="debug"> <appender-ref ref="FILE" /> </root>
---------- Forwarded message ---------- From: mohit gupta<[email protected]> Date: Thu, Apr 19, 2012 at 10:06 PM Subject: Redirecting logs to a file instead of console on tomcat? To: XWiki Users<[email protected]>
I have gone thru http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Logging. As per logback.xml(inside in MyApp/WEB_INF/classes), looks like it relies on the fact that container will redirect all the console to logfile automaticcaly. But it is not happening. I am using tomcat 6. i want to put all the possible logs i.e log.info.log.warn,log.error,log.debug,log.fatal inside log file
For logging i am using below code snippet private static final Log log = org.apache.commons.logging.LogFactory.getLog(AuthServiceImpl.class);// declared as insiance variable under AuthServiceImpl.class
You shouldn't use commons-logging, but slf4j: private static final Logger LOGGER = LoggerFactory.getLogger(AuthServiceImpl.class); I don't understand what you mean by "declared as instance variable". If it's "static final", then it's not an instance variable, but a static constant member.
then in my public method i am doing the logging as
log.error("Testing AuthServiceImpl Reply = ");
But its printing the logs on tomcat console. Guys really i have no idea how to print the to file instead of console.Inside logback.xml(inside in MyApp/WEB_INF/classes) i can see below setting. I have really no idea what is happening?
Thanks in advance.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Thanks Sergiu. On Thu, Apr 19, 2012 at 11:27 PM, Sergiu Dumitriu <[email protected]> wrote:
On 04/19/2012 01:51 PM, mohit gupta wrote:
Now as per http://logback.qos.ch/manual/**joran.html<http://logback.qos.ch/manual/joran.html>, i tried to use file Appender to log the message to file* but no help*. Here is added code
snippet in logback.xml
<appender name="FILE" class="ch.qos.logback.core.**FileAppender"> <file>myApp.log</file>
You should use an absolute file path, since this filename could end up anywhere, depending on how Tomcat was started and what it considers the "current directory". Make sure the location you provide is writable by the owner of the tomcat process.
<layout class="ch.qos.logback.core.**ConsoleAppendert">
^ typo here, ConsoleAppender[t]
<Pattern>%date %level [%thread] %logger{10} [%file:%line]
%msg%n</Pattern> </layout> </appender>
<root level="debug"> <appender-ref ref="FILE" /> </root>
---------- Forwarded message ---------- From: mohit gupta<[email protected]> Date: Thu, Apr 19, 2012 at 10:06 PM Subject: Redirecting logs to a file instead of console on tomcat? To: XWiki Users<[email protected]>
I have gone thru http://platform.xwiki.org/**xwiki/bin/view/AdminGuide/**Logging<http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Logging>. As per logback.xml(inside in MyApp/WEB_INF/classes), looks like it relies on the fact that container will redirect all the console to logfile automaticcaly. But it is not happening. I am using tomcat 6. i want to put all the possible logs i.e log.info.log.warn,log.error,**log.debug,log.fatal inside log file
For logging i am using below code snippet private static final Log log = org.apache.commons.logging.**LogFactory.getLog(** AuthServiceImpl.class);// declared as insiance variable under AuthServiceImpl.class
You shouldn't use commons-logging, but slf4j:
private static final Logger LOGGER = LoggerFactory.getLogger(** AuthServiceImpl.class);
I don't understand what you mean by "declared as instance variable". If it's "static final", then it's not an instance variable, but a static constant member.
then in my public method i am doing the logging as
log.error("Testing AuthServiceImpl Reply = ");
But its printing the logs on tomcat console. Guys really i have no idea how to print the to file instead of console.Inside logback.xml(inside in MyApp/WEB_INF/classes) i can see below setting. I have really no idea what is happening?
Thanks in advance.
-- Sergiu Dumitriu http://purl.org/net/sergiu/ ______________________________**_________________ users mailing list [email protected] http://lists.xwiki.org/**mailman/listinfo/users<http://lists.xwiki.org/mailman/listinfo/users>
participants (2)
-
mohit gupta -
Sergiu Dumitriu