My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

SLF4JExtension  
SLF4J Logging Extension
Extension
Updated Feb 19, 2011 by u...@thomas-daily.de

Introduction

This is a simple extension to Morphia to redirect logging to SFL4J.

Using

Add this at the start of your application. It is done once, statically.

MorphiaLoggerFactory.registerLogger(SLF4JLoggerImplFactory.class);

Dependencies

Manual

Maven

  • If you use Maven2 to manage your project, you can reference Morphia as a dependency.
    • Repo: http://morphia.googlecode.com/svn/mavenrepo/
    • Project Settings:
    • <dependency>
              <groupId>com.google.code.morphia</groupId>
              <artifactId>morphia-logging-slf4j</artifactId>
              <version>0.99</version>
      </dependency>
Comment by mdpha...@gmail.com, Apr 24, 2011

SLF4JLoggerImplFactory is actually com.google.code.morphia.logging.slf4j.SLF4JLogrImplFactory

Comment by China.Yo...@gmail.com, May 10, 2011

what does start of application mean? where? 2011-5-11 0:00:05 com.google.code.morphia.mapping.Mapper validate 警告: The type(s) for the query/update may be inconsistent; using an instance of type 'org.bson.types.ObjectId?' for the field 'com.joyful.canyin.shared.entity.Restaurant.id' which is declared as 'java.lang.String'

--@--com.joyful.canyin.server.dao.mongo.RestaurantImpl?.getRestaurantById(RestaurantImpl?.java:40)
I don't want to show this log ? what can I do for this? I am waiting for your help... thank you

Comment by zhong...@gmail.com, Aug 24, 2011

how to use morphia logging?

Comment by zhong...@gmail.com, Aug 24, 2011

OK, figure out: 1. download morphia-logging-slf4j.jar and drop to your classpath 2. in your spring xml:

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.google.code.morphia.logging.MorphiaLoggerFactory.registerLogger"/> <property name="arguments">
<list>
<value>com.google.code.morphia.logging.slf4j.SLF4JLogrImplFactory</value>
</list>
</property>
</bean>

Comment by alexsap...@gmail.com, Nov 1, 2011

I cant get it to work with jboss as 7 and resteasy i put the static method static {

MorphiaLoggerFactory?.reset(); MorphiaLoggerFactory?.registerLogger(com.google.code.morphia.logging.slf4j.SLF4JLogrImplFactory.class);
}

and i am having the same error... java.lang.ClassNotFoundException?: org.slf4j.LoggerFactory? from "deployment.Service.war:main" from Service Module Loader?

What i am doing wrong i have the jars in my lib folder morphia-1.00-SNAPSHOT.jar morphia-validation-0.99.jar morphia-logging-slf4j-0.99.jar

Comment by dieter.m...@gmail.com, Nov 11, 2011

When using SpringConfig?.java use:

static {
MorphiaLoggerFactory?.registerLogger(SLF4JLogrImplFactory.class);
}
Comment by jaronsampson, Mar 23, 2012

In order to get 0.99 working with spring, I had to use the following configuration:

<bean id="morphiaSlf4j" class="java.lang.Class" factory-method="forName">
<constructor-arg value="com.google.code.morphia.logging.slf4j.SLF4JLogrImplFactory"/>
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.google.code.morphia.logging.MorphiaLoggerFactory.registerLogger"/>
<property name="arguments">
<list>
<ref local="morphiaSlf4j"/>
</list>
</property>
</bean>

I believe the documentation in the above wiki entry will work given the fixes in the current trunk code.

Comment by hendy.soluvas@gmail.com, Apr 13, 2012

Why does SLF4J logging become an "extension"? It should simply use the SLF4J API... It's a reasonable dependency.


Sign in to add a comment
Powered by Google Project Hosting