Thanks Robert, that worked a treat. In summary I needed the following for a simple Ant build:
slf4j-api-1.7.5.jar slf4j-ext-1.7.5.jar log4j-slf4j-impl-2.0-beta4.jar log4j-api-2.0-beta4.jar log4j-core-2.0-beta4.jar In a Maven project, the dependencies also downloaded the following: cal10n-api-0.7.4.jar Thanks again. Mark. On Thu04 04 13, at 23:58, Robert Elliot <[email protected]> wrote: > You may be having issues because log4j 2.0-alpha-2 is built against slf4j > 1.6.4. There is a later version of Log4J 2 available. > > Try this: > > <dependency> > <groupId>org.slf4j</groupId> > <artifactId>slf4j-api</artifactId> > <version>1.7.5</version> > </dependency> > <dependency> > <groupId>org.slf4j</groupId> > <artifactId>slf4j-ext</artifactId> > <version>1.7.5</version> > <scope>runtime</scope> > </dependency> > <dependency> > <groupId>org.apache.logging.log4j.adapters</groupId> > <artifactId>log4j-slf4j-impl</artifactId> > <version>2.0-beta4</version> > <scope>runtime</scope> > </dependency> > <dependency> > <groupId>org.apache.logging.log4j</groupId> > <artifactId>log4j-core</artifactId> > <version>2.0-beta4</version> > <scope>runtime</scope> > </dependency> > > If not using Maven, the full set of jars you need on the classpath is: > > org.slf4j:slf4j-api:1.7.5 > org.slf4j:slf4j-ext:1.7.5 > ch.qos.cal10n:cal10n-api:0.7.4 > org.apache.logging.log4j.adapters:log4j-slf4j-impl:2.0-beta4 > org.apache.logging.log4j:log4j-api:2.0-beta4 > org.apache.logging.log4j:log4j-core:2.0-beta4 > > This class then works for me: > > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > > public class Slf4jUser { > > public static void main(String[] args) { > Logger logger = LoggerFactory.getLogger("loggername"); > logger.error("hello world"); > } > } > > Rob > > On 4 Apr 2013, at 17:13, Patrick <[email protected]> wrote: > >> >> On Apr 4, 2013, at 2:13 AM, Mark James wrote: >> >>> I am new to SLF4J and Java logging in general. >>> >>> After some research it seems the best option for a flexible and scalable >>> logging environment is SLF4J and log4j 2. As I understand it I use SLF4J >>> as the interface (facade) and log4j 2 as the implementation, this also >>> means I can change the implementation (for example to java.util.logging) in >>> the future. >>> >>> My problem is setting up a simple hello world project (I'm using NetBeans) >>> as I do not know which combination of jar files are needed. >>> >>> Having downloaded SLF4J and log4j 2, there are lots of libraries in each >>> project and I cannot find a combination that works, would someone be kind >>> enough to tell me exactly which files (full filenames) I need from each >>> project. >> >> I tried to get it working, but I didn' have much luck. The one thing I did >> figure out is that it seems that the normal log4j bindings only work with >> log4j 1.x. There are some that work better form the apache website, but >> they still crash and I can't get any output. >> >> >> For anyone who's interested, this is the Maven config that got me the >> farthest: >> <dependency> >> <groupId>org.slf4j</groupId> >> <artifactId>slf4j-api</artifactId> >> <version>1.7.5</version> >> </dependency> >> <dependency> >> <groupId>org.apache.logging.log4j</groupId> >> <artifactId>log4j-api</artifactId> >> <version>2.0-alpha2</version> >> </dependency> >> <dependency> >> <groupId>org.apache.logging.log4j</groupId> >> <artifactId>log4j-core</artifactId> >> <version>2.0-alpha2</version> >> </dependency> >> <dependency> >> <groupId>org.apache.logging.log4j</groupId> >> <artifactId>slf4j-impl</artifactId> >> <version>2.0-alpha2</version> >> </dependency> >> _______________________________________________ >> slf4j-user mailing list >> [email protected] >> http://mailman.qos.ch/mailman/listinfo/slf4j-user > > _______________________________________________ > slf4j-user mailing list > [email protected] > http://mailman.qos.ch/mailman/listinfo/slf4j-user _______________________________________________ slf4j-user mailing list [email protected] http://mailman.qos.ch/mailman/listinfo/slf4j-user
