0

I am using Payara 4.1 and Netbeans 8.1.

When I run my application, these four lines are among the first to be logged:

 #!## LogManagerService.postConstruct : rootFolder=/opt/payara41/glassfish
 #!## LogManagerService.postConstruct : templateDir=/opt/payara41/glassfish/lib/templates
 #!## LogManagerService.postConstruct : src=/opt/payara41/glassfish/lib/templates/logging.properties
 #!## LogManagerService.postConstruct : dest=/opt/payara41/glassfish/domains/domain1/config/logging.properties

I added the line org.springframework=WARNING at the end of the last logging.properties file given above, and restarted my server. That didn't seem to have an effect. When I open the asadmin shell /opt/payara41/bin/asadmin and run list-log-attributes, here is what I get:

asadmin> list-log-attributes
com.sun.enterprise.server.logging.GFFileHandler.excludeFields   <>
com.sun.enterprise.server.logging.GFFileHandler.file    <${com.sun.aas.instanceRoot}/logs/server.log>
com.sun.enterprise.server.logging.GFFileHandler.flushFrequency  <1>
com.sun.enterprise.server.logging.GFFileHandler.formatter   <com.sun.enterprise.server.logging.ODLLogFormatter>
com.sun.enterprise.server.logging.GFFileHandler.logtoConsole    <false>
com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles <0>
com.sun.enterprise.server.logging.GFFileHandler.multiLineMode   <true>
com.sun.enterprise.server.logging.GFFileHandler.retainErrorsStasticsForHours    <0>
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes    <2000000>
com.sun.enterprise.server.logging.GFFileHandler.rotationOnDateChange    <false>
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes  <0>
com.sun.enterprise.server.logging.SyslogHandler.useSystemLogging    <false>
handlerServices <com.sun.enterprise.server.logging.GFFileHandler,com.sun.enterprise.server.logging.SyslogHandler>
handlers    <java.util.logging.ConsoleHandler>
java.util.logging.ConsoleHandler.formatter  <com.sun.enterprise.server.logging.UniformLogFormatter>
java.util.logging.FileHandler.count <1>
java.util.logging.FileHandler.formatter <java.util.logging.XMLFormatter>
java.util.logging.FileHandler.limit <50000>
java.util.logging.FileHandler.pattern   <%h/java%u.log>
log4j.logger.org.hibernate.validator.util.Version   <warn>
org.springframework <WARNING>
Command list-log-attributes executed successfully.

I have tried the suggestions given in this SO question but that didn't work. I'm stumped. :( I really do not want to see all those INFO logging lines printed by the spring framework.

=== EDIT ===

Here is what is in my log4j.properties (copied from SO):

# Define the root logger with appender file
log4j.rootLogger = DEBUG, stdout

# Define the file appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Set the name of the logs destination
log4j.appender.stdout.target=System.out

# Set the immediate flush to true (default)
log4j.appender.stdout.ImmediateFlush=true

# Set the threshold to debug mode
log4j.appender.stdout.Threshold=debug

# Set the append to false, overwrite
log4j.appender.stdout.Append=false

# Define the layout for appender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%d{yyyy-MM-dd}:%m%n

log4j.logger.org.springframework=WARNING

Here are all the places I have copied that file to:

$PROJECT_DIR/src/log4j.properties
$PROJECT_DIR/src/main/resources/META-INF/log4j.properties
$PROJECT_DIR/src/main/webapp/WEB-INF/log4j.properties
$PROJECT_DIR/src/main/webapp/WEB-INF/classes/log4j.properties
$PROJECT_DIR/target/$PROJECT-1.0/WEB-INF/log4j.properties
$PROJECT_DIR/target/$PROJECT-1.0/WEB-INF/classes/log4j.properties
$PROJECT_DIR/target/$PROJECT-1.0/WEB-INF/classes/META-INF/log4j.properties
$PROJECT_DIR/target/classes/META-INF/log4j.properties
/opt/payara41/glassfish/domains/domain1/config/log4j.properties

In addition, I have added log4j.logger.org.springframework=WARNING and org.springframework=WARNING to Configurations > server-config > Logger Settings > Module Log Levels in the Payara UI. Nothing is working. Payara's server log still has INFO lines for the spring framework.

Community
  • 1
  • 1
nullstellensatz
  • 756
  • 8
  • 18
  • Just for clarity: the file you edit is a logging.properties file that is part of the server? If so: Glassfish uses java.util.logging internally, while Spring seems to use log4j. If you want to control the spring logging I would expect you to add a log4j.properties file to your application and put the necessary filters there. – Gimby Mar 17 '16 at 11:00
  • As mentioned in my question, I already trying adding that file in my WEB-INF directory. Didn't work. – nullstellensatz Mar 17 '16 at 16:38
  • WEB-INF or WEB-INF/classes? It needs to be on the classpath so it needs to go in WEB-INF/classes. – Gimby Mar 18 '16 at 08:15
  • I see you're using Maven, the one proper directory to put the log4j.properties file is `src/main/resources`, which when the application is built and deployed will make it end up in WEB-INF/classes. – Gimby Mar 18 '16 at 14:49

1 Answers1

0

I tried everything that has been suggested so far, to no avail. So I ended up doing something pretty hacky. I wrote my own log handler and installed it to domain1/lib/ext:

package org.springsuppressor;

import java.util.logging.ConsoleHandler;
import java.util.logging.Level;

public class MyHandler extends ConsoleHandler {

  public MyHandler() {
    super();
    setLevel(Level.WARNING);
  }
}

The handler above sets the log level for all loggers to WARNING. I could suppress messages for just the spring framework, but I don't yet need to do that.

nullstellensatz
  • 756
  • 8
  • 18