Unified logging
Jason Harrop <[email protected]>
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <CAM-hvXf6kSCcz82_f=3Ek87vdditLg8B6EZaezbzQ3X6c-Qi0g@mail.gmail.com> |
This message is about controlling the Java logging emitted by your
IKVM'd dlls, and coercing them into using the logging infrastructure
you have in place on the .NET side.
By now, many Java libraries use slf4j for logging, so the user of the
library can use their preferred logging framework to display the logs.
Ideally, system-wide logging can be configured in a single place.
Common.Logging is a similar idea for .NET: http://netcommon.sourceforge.net/
It supports Log4Net, NLog, System.Console, System.Diagnostics.Trace etc
Wouldn't it be nice if your slf4j logs could be routed to the
preferred .NET logging implementation?
I thought so.. and it turns out that binding Common.Logging to slf4j
is pretty straightforward:
https://github.com/plutext/slf4j-net-commons-logging/tree/master/src/main/java
To try it out, you need 3 DLLs:
- IKVM'd slf4j-api
- IKVM'd version of the above source
- Common.Logging
Then just follow the Common.Logging doco to configure:
http://netcommon.sourceforge.net/documentation.html
You can get the 3 DLLs from NuGet:
- https://www.nuget.org/packages/slf4j-api/1.7.5
- https://www.nuget.org/packages/slf4j-NetCommonLogging/1.0.0
- https://www.nuget.org/packages/Common.Logging/
or if you aren't using NuGet:
https://github.com/plutext/slf4j-net-commons-logging/tree/master/dotNET/lib/net20
and https://github.com/net-commons/common-logging/downloads
If you get a ClassNotFoundException, one way around that may be to add:
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.slf4j.impl.StaticLoggerBinder)));
Hope this is of interest / helps somebody..
cheers .. Jason
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk