Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert logging to logback predominantly via slf4j #1006

Merged
merged 33 commits into from
Apr 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fe24c2f
Initial commit after using SLF4J Migrator.
ximenesuk Feb 19, 2013
6766ed3
Two changes made by hand to preserve the original encoding and minimi…
ximenesuk Feb 19, 2013
46f9929
Fix two-line log factory invocations missed by migrator.
ximenesuk Feb 18, 2013
14dd05e
Change argument types to Logger.
ximenesuk Feb 18, 2013
4c7dbdb
Add logback jars.
ximenesuk Feb 18, 2013
e5313a2
Update slf4j jars.
ximenesuk Feb 19, 2013
2a1efd0
Update omero.properties
ximenesuk Feb 19, 2013
24e3e45
Remove unused CommonsLoggingAdapter.
ximenesuk Feb 19, 2013
00bb2cf
Resolve conflict between slf4j.Logger and log4j.Logger
ximenesuk Feb 18, 2013
94e34ee
Change fatal() to error().
ximenesuk Feb 18, 2013
8277002
Force log arguments to Strings.
ximenesuk Feb 18, 2013
c1855d5
Fix a few tests missed by the migrator and not picked up in other com…
ximenesuk Feb 19, 2013
3ee1480
Translated log4j-cli.properties to logback-cli.xml
ximenesuk Feb 19, 2013
5add9ff
Reverting changes under dsl as velocity is dependent on log4j
ximenesuk Feb 26, 2013
5537cde
Add logback dependency, remove slf4j-log4j12 dependency.
ximenesuk Feb 26, 2013
90fadd9
Update perf4j to exploit logback more fully.
ximenesuk Feb 27, 2013
2eb1812
Update configuration to logback with minimal logback.xml file
ximenesuk Feb 27, 2013
cdcae3d
Replicate most of log4j config
ximenesuk Feb 27, 2013
df19371
Replicate and add indexing logging.
ximenesuk Feb 27, 2013
b8fe39d
Removing configureLogging.
ximenesuk Apr 1, 2013
f9d96cf
Upgrade ehcache to 2.1.0, remove jsr107cache.
ximenesuk Mar 5, 2013
75a7c08
Change perf4j to use slf4j logging and add config.
ximenesuk Apr 4, 2013
6549890
Add jcl-over-slf4j to catch springframework logging.
ximenesuk Apr 4, 2013
4ebc238
Add back config for build logging.
ximenesuk Apr 5, 2013
a2e5bde
Remove log4j config files from etc.
ximenesuk Apr 8, 2013
56a4686
Move apacheds server dependencies to allow other unit tests to run.
ximenesuk Apr 9, 2013
2b01d50
Temporary commit for files that need further work.
ximenesuk Feb 25, 2013
c5c4711
Modify two blitz tests to use logback directly.
ximenesuk Apr 9, 2013
136452b
Fix comment errors
ximenesuk Apr 11, 2013
29c0c61
Fix dsl errors
ximenesuk Apr 11, 2013
2589d8e
Reverting EOL changes.
ximenesuk Apr 11, 2013
0fc1f8c
Changes to log config.
ximenesuk Apr 11, 2013
50cd930
Removing unnecessary imports.
ximenesuk Apr 11, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 25 additions & 0 deletions components/blitz/resources/logback-cli.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- For assistance related to logback-translator or configuration -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
<!-- -->
<!-- For professional support please see -->
<!-- http://www.qos.ch/shop/products/professionalSupport -->
<!-- -->
<configuration>
<appender name="stderr" class="ch.qos.logback.core.ConsoleAppender">
<target>System.err</target>
<encoder>
<pattern>%d %-10.10r [%10.10t] %-6.6p %40.40c %x - %m</pattern>
</encoder>
</appender>
<logger name="ome.adapters" level="error"/>
<logger name="ome" level="info"/>
<logger name="ome.formats" level="info"/>
<logger name="loci" level="error"/>
<logger name="ome.system" level="warn"/>
<root level="warn">
<appender-ref ref="stderr"/>
</root>
</configuration>
6 changes: 3 additions & 3 deletions components/blitz/src/ome/formats/OMEROImportFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import ome.formats.importer.util.ErrorHandler.EXCEPTION_EVENT;
import omero.model.Pixels;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* test fixture for importing files without a GUI. Sample usage:
Expand All @@ -48,7 +48,7 @@
*/
public class OMEROImportFixture {

Log log = LogFactory.getLog(OMEROImportFixture.class);
Logger log = LoggerFactory.getLogger(OMEROImportFixture.class);

protected OMEROMetadataStoreClient store;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@
import omero.util.TempFileManager;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import Glacier2.CannotCreateSessionException;
import Glacier2.PermissionDeniedException;
Expand All @@ -226,7 +226,7 @@ public class OMEROMetadataStoreClient
implements MetadataStore, IMinMaxStore, IObjectContainerStore
{
/** Logger for this class */
private Log log = LogFactory.getLog(OMEROMetadataStoreClient.class);
private Logger log = LoggerFactory.getLogger(OMEROMetadataStoreClient.class);

private MetadataStorePrx delegate;

Expand Down Expand Up @@ -929,7 +929,7 @@ private void closeQuietly(omero.api.StatefulServiceInterfacePrx prx)
log.debug("Communicator already closed; cannot close " + prx);
} catch (Exception e) {
log.warn("Exception closing " + prx, e);
log.debug(e);
log.debug(e.toString()); // slf4j migration: toString()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/blitz/src/ome/formats/OverlayMetadataStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import omero.model.Roi;
import omero.model.RoiI;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Client side metadata store implementation that only deals with overlays. At
Expand All @@ -58,7 +58,7 @@
public class OverlayMetadataStore extends DummyMetadata
{
/** Logger for this class. */
private static Log log = LogFactory.getLog(OverlayMetadataStore.class);
private static Logger log = LoggerFactory.getLogger(OverlayMetadataStore.class);

private List<Pixels> pixelsList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import omero.RLong;
import omero.RString;
Expand All @@ -50,7 +50,7 @@
public class IQueryEnumProvider implements EnumerationProvider
{
/** Logger for this class. */
private static Log log = LogFactory.getLog(IQueryEnumProvider.class);
private static Logger log = LoggerFactory.getLogger(IQueryEnumProvider.class);

/** Enumeration cache. */
private Map<Class<? extends IObject>, HashMap<String, IObject>> enumCache =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

import org.apache.commons.io.DirectoryWalker;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Utility class which given any {@link File} object will determine the correct
Expand Down Expand Up @@ -112,7 +112,7 @@ public static class CANCEL extends RuntimeException {

private static final long serialVersionUID = 1L;};

final private static Log log = LogFactory.getLog(ImportCandidates.class);
final private static Logger log = LoggerFactory.getLogger(ImportCandidates.class);

final public static int DEPTH = Integer.valueOf(
System.getProperty("omero.import.depth","4"));
Expand Down
26 changes: 13 additions & 13 deletions components/blitz/src/ome/formats/importer/ImportConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
import omero.model.Annotation;
import omero.model.FilesetVersionInfo;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// import org.apache.log4j.Level; CGB: Needs replacing with logback equivalent.

/**
* Utility class which configures the Import.
Expand All @@ -47,7 +46,7 @@
*/
public class ImportConfig {

private final static Log log = LogFactory.getLog(ImportConfig.class);
private final static Logger log = LoggerFactory.getLogger(ImportConfig.class);

/**
* Delimiter used to encode multiple servers in one preferences value.
Expand Down Expand Up @@ -264,18 +263,19 @@ public void fillVersionInfo(FilesetVersionInfo versionInfo) {
// TODO: add java version info
}

//CGB: Need replacing with logback equivalent.
/**
* Modifies the Log4j logging level of everything under the
* <code>ome.format</code> and <code>loci</code> package hierarchically.
* @param level if null, then {@link #ini#getDebugLevel()} will be used.
*/
public void configureDebug(Level level) {
if (level == null) {
level = Level.toLevel(ini.getDebugLevel());
}
Logger.getLogger("ome.formats").setLevel(level);
Logger.getLogger("loci").setLevel(level);
}
// public void configureDebug(Level level) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will certainly affect the results of what we get from import logging until it's been fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there I tried a fix but it looks like it will need to be fixed in the context of moving Insight/Importer away from log4j

// if (level == null) {
// level = Level.toLevel(ini.getDebugLevel());
// }
// org.apache.log4j.Logger.getLogger("ome.formats").setLevel(level);
// org.apache.log4j.Logger.getLogger("loci").setLevel(level);
// }

//
// Login methods
Expand Down Expand Up @@ -679,7 +679,7 @@ public void saveAll() {
prefs.flush();
ini.flushPreferences();
} catch (BackingStoreException e) {
log.error(e);
log.error(e.toString()); // slf4j migration: toString()
throw new RuntimeException(e);
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/blitz/src/ome/formats/importer/ImportFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import ome.formats.OMEROMetadataStoreClient;
import omero.model.Dataset;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* test fixture for importing files without a GUI.
Expand All @@ -38,7 +38,7 @@
public class ImportFixture
{

Log log = LogFactory.getLog(ImportFixture.class);
Logger log = LoggerFactory.getLogger(ImportFixture.class);

@SuppressWarnings("unused")

Expand Down
7 changes: 4 additions & 3 deletions components/blitz/src/ome/formats/importer/ImportLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import loci.formats.FormatException;
import loci.formats.FormatReader;

import ome.formats.OMEROMetadataStoreClient;
import ome.formats.importer.util.ErrorHandler;
import ome.services.blitz.repo.path.ClientFilePathTransformer;
Expand Down Expand Up @@ -53,8 +54,8 @@
import omero.model.Pixels;
import omero.model.Screen;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* support class for the proper usage of {@link OMEROMetadataStoreClient} and
Expand All @@ -72,7 +73,7 @@
*/
public class ImportLibrary implements IObservable
{
private static Log log = LogFactory.getLog(ImportLibrary.class);
private static Logger log = LoggerFactory.getLogger(ImportLibrary.class);

/** The class used to identify the dataset target.*/
private static final String DATASET_CLASS = "omero.model.Dataset";
Expand Down
6 changes: 3 additions & 3 deletions components/blitz/src/ome/formats/importer/OMEROWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import omero.model.Channel;
import omero.model.Pixels;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Brian Loranger brain at lifesci.dundee.ac.uk
Expand All @@ -61,7 +61,7 @@
public class OMEROWrapper extends MinMaxCalculator {

@SuppressWarnings("unused")
private final static Log log = LogFactory.getLog(OMEROWrapper.class);
private final static Logger log = LoggerFactory.getLogger(OMEROWrapper.class);

private ChannelSeparator separator;
private ChannelFiller filler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
import omero.model.Dataset;
import omero.model.Screen;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// import org.apache.log4j.Level; CGB: Needs replacing with logback equivalent.

/**
* The base entry point for the CLI version of the OMERO importer.
Expand All @@ -42,7 +41,7 @@
*/
public class CommandLineImporter {
/** Logger for this class. */
private static Log log = LogFactory.getLog(CommandLineImporter.class);
private static Logger log = LoggerFactory.getLogger(CommandLineImporter.class);

/** Name that will be used for usage() */
private static final String APP_NAME = "importer-cli";
Expand Down Expand Up @@ -326,7 +325,8 @@ public static void main(String[] args) {
while ((a = g.getopt()) != -1) {
switch (a) {
case 1: {
config.configureDebug(Level.toLevel(g.getOptarg()));
// CGB: Needs replacing with logback equivalent.
// config.configureDebug(Level.toLevel(g.getOptarg()));
break;
}
case 2: {
Expand Down Expand Up @@ -446,11 +446,12 @@ public static void main(String[] args) {
}
}

// CGB: Needs replacing with logback equivalent.
// Let the user know at what level we're logging
log.info(String.format(
"Log levels -- Bio-Formats: %s OMERO.importer: %s",
Logger.getLogger("loci").getLevel(),
Logger.getLogger("ome.formats").getLevel()));
//log.info(String.format(
// "Log levels -- Bio-Formats: %s OMERO.importer: %s",
// org.apache.log4j.Logger.getLogger("loci").getLevel(),
// org.apache.log4j.Logger.getLogger("ome.formats").getLevel()));

List<Annotation> annotations =
toTextAnnotations(annotationNamespaces, textAnnotations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import ome.formats.importer.ImportCandidates.SCANNING;
import ome.formats.importer.util.ErrorContainer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* {@link IObserver} based on the gui ErrorHandler code which collects all
Expand All @@ -30,7 +30,7 @@
*/
public class ErrorHandler extends ome.formats.importer.util.ErrorHandler {

private final static Log log = LogFactory.getLog(ErrorHandler.class);
private final static Logger log = LoggerFactory.getLogger(ErrorHandler.class);

public ErrorHandler(ImportConfig config) {
super(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import omero.model.IObject;
import omero.model.Pixels;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Basic import process monitor that writes information to the log.
Expand All @@ -25,7 +25,7 @@
*/
public class LoggingImportMonitor implements IObserver
{
private static Log log = LogFactory.getLog(LoggingImportMonitor.class);
private static Logger log = LoggerFactory.getLogger(LoggingImportMonitor.class);

public void update(IObservable importLibrary, ImportEvent event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import ome.formats.importer.IObserver;
import ome.formats.importer.ImportEvent;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A {@link Runnable} which keeps a {@link Connector}'s server side resources
Expand All @@ -49,7 +49,7 @@
public class ClientKeepAlive implements Runnable, IObservable
{
/** Logger for this class. */
private static Log log = LogFactory.getLog(ClientKeepAlive.class);
private static Logger log = LoggerFactory.getLogger(ClientKeepAlive.class);

/** The connector we're trying to keep alive. */
private OMEROMetadataStoreClient client;
Expand Down Expand Up @@ -136,8 +136,8 @@ public void notifyObservers(ImportEvent event)
observer.update(this, event);
} catch (Exception e)
{
log.error(e);
log.error(e.toString()); // slf4j migration: toString()
}
}
}
}
}
Loading