Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting logging level for an application deployed via Embedded Glassfish 4 and Maven
    primarykey
    data
    text
    <p>I'm having trouble configuring logging correctly for a deployed application using Maven and Embedded Glassfish 4. The server will show log messages that I have set to INFO but not DEBUG. The logging config I have works fine when deployed to standalone Glassfish 4 but I'm unable to work out why it doesn't on the embedded version.</p> <p>I have the following dependencies for my app in the pom.xml:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt; &lt;artifactId&gt;logback-classic&lt;/artifactId&gt; &lt;version&gt;1.0.13&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt; &lt;artifactId&gt;groovy-all&lt;/artifactId&gt; &lt;version&gt;2.0.7&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>And the embedded glassfish plugin is configured as follows in the pom.xml:</p> <pre><code> &lt;plugin&gt; &lt;groupId&gt;org.glassfish.embedded&lt;/groupId&gt; &lt;artifactId&gt;maven-embedded-glassfish-plugin&lt;/artifactId&gt; &lt;version&gt;4.0&lt;/version&gt; &lt;configuration&gt; &lt;goalPrefix&gt;embedded-glassfish&lt;/goalPrefix&gt; &lt;name&gt;ia&lt;/name&gt; &lt;app&gt;target/${project.artifactId}-${project.version}&lt;/app&gt; &lt;autoDelete&gt;true&lt;/autoDelete&gt; &lt;configFile&gt;glassfish/domain.xml&lt;/configFile&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;!-- Start embedded GlassFish --&gt; &lt;execution&gt; &lt;id&gt;start&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;start&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;deploy&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;deploy&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;stop&lt;/id&gt; &lt;phase&gt;post-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;undeploy&lt;/goal&gt; &lt;goal&gt;stop&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;!-- Run some admin commands --&gt; &lt;execution&gt; &lt;id&gt;admin&lt;/id&gt; &lt;phase&gt;install&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;admin&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;commands&gt; &lt;param&gt;list-applications&lt;/param&gt; &lt;/commands&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.main.extras&lt;/groupId&gt; &lt;artifactId&gt;glassfish-embedded-all&lt;/artifactId&gt; &lt;version&gt;4.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.oracle&lt;/groupId&gt; &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt; &lt;version&gt;${ojdbc6.version}&lt;/version&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/plugin&gt; </code></pre> <p>Note - I have used the domain.xml created using a standalone instance of Glassfish to provide me with various pre-configured resources.</p> <p>And my logback.groovy config file looks like:</p> <pre><code>def appenderList = ["ROLLING"] def WEBAPP_DIR = "." def APPENDER_PATTERN = "%d{yyyy-MM-dd HH:mm:ss.SSS}:%5p:%c{1}:%M:%L: %m%n"; def consoleAppender = true; println "Hostname is ${hostname}" // does hostname match PROD? if (hostname =~ /PROD/) { // TODO: replace this with actual produtcion server host URL pattern WEBAPP_DIR = "/opt/myapp" // TODO: replace with actual web app directory consoleAppender = false } else { appenderList.add("CONSOLE") logger("uk.co.myapp", DEBUG, ["CONSOLE"]) } if (consoleAppender) { appender("CONSOLE", ConsoleAppender) { encoder(PatternLayoutEncoder) { pattern = "${APPENDER_PATTERN}" } } } appender("ROLLING", RollingFileAppender) { file = "${WEBAPP_DIR}/log/ia-log.log" encoder(PatternLayoutEncoder) { pattern = "${APPENDER_PATTERN}" } rollingPolicy(TimeBasedRollingPolicy) { fileNamePattern = "${WEBAPP_DIR}/log/ia-log-%d{yyyy-MM}.zip" } } root(INFO, appenderList) </code></pre> <p>I've worked out how to change the logging.properties for the Glassfish server, but so far my changes to these settings have no effect on my deployed application, they just spew out loads of server related log messages which I don't care about.</p> <p>I'm hoping someone has experienced this same problem and worked out how to configure it properly.</p> <p>Preferably I want to stick with logback but if it means switching logging frameworks to solve this problem then I'll be happy to do so.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload