<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<font style="" face="Courier New">Hi,</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"><br></font><font style="" face="Courier New">I'm developing a Java web application through Tomcat with Java servlets. In my constructor for one servlet I call the following code:</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"><br></font><font style="" face="Courier New">public MyServlet () {</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"> // Initialise the logger</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"> logger = (Logger)LoggerFactory.getLogger("application");</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"> logger.debug("Starting application");</font><font style="" face="Courier New"><br></font><font style="" face="Courier New">}</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"><br>My logback.xml configuration file is the following:<br><br><?xml version="1.0" encoding="UTF-8"?><br><br><configuration debug="true"><br><br> <appender name="FILE"<br> class="ch.qos.logback.core.FileAppender"><br> <file>application.log</file><br> <append>true</append><br><br> <encoder><br> <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n<br> </pattern><br> </encoder><br> </appender><br><br> <logger name="application" level="INFO"><br> <appender-ref ref="FILE" /><br> </logger><br></configuration><br><br>When I launch the web app, the constructor is called by Tomcat, which should run the above code, but no file ("application.log") is created and no output is done anywhere.<br><br>Within the same project, I try to test the Logger. In a junit test I have the following:<br><br>public class TestLogging extends TestCase {<br> public void testApplicationLogger() {<br> // Initialise the logger<br> Logger logger = (Logger)LoggerFactory.getLogger("application");<br> logger.error("Starting application");<br> }<br>}<br><br>This generates a file, a outputs "201 [main] ERROR application - Starting application"<br><br>Why can't I get the logger to output anything from the servlet?<br><br>Regards,<br></font><font style="" face="Courier New">Sotirios</font> </div></body>
</html>