[slf4j-dev] Repost
Thorbjørn Ravn Andersen
thunderaxiom at gmail.com
Thu Aug 28 22:39:44 CEST 2008
Ceki Gulcu skrev den 25-08-2008 15:53:
> Thank you for posting your message.
>
> For those who missed older messages, Thorbjørn is adapting his work on adding
> logging statements on classes through byte code generation. This was published
> in an article entitled "Add Logging at Class Load Time with Java
> Instrumentation". The URL is
>
> http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html
>
Enclosed please find an initial conversion just so people can see what
this is about.
=== LOADING SOURCE
I am using eclipse - follow these steps to set up starting with a blank
workspace:
* Save the attached zip file, e.g to C:\slf4j-agent-projects.zip
* In Eclipse choose File -> Import
* Open "General", click "Existing projects into workspace". Click Next
* Select "Select archive file" radiobutton, and browse to the archive
saved before.
The projects "org.slf4j.instrumentation" and
"slf4j-instrumentation-helloworld" are found, and both are checked.
* Click "Finish"
The projects are loaded into Eclipse. You most likely want to switch to
the Java perspective (Windows->Open Perspective -> Other -> Java).
==== RUNNING DEMO IN ECLIPSE
* Open the "slf4j-instrumentation-helloworld" project, and open the
"build.xml" file.
You should see colours in the build.xml window indicating that Eclipse
knows about Ant.
* Open the outline view with Windows->Show view ->Outline"
You should see a tree view of the xml file in the outline view, right
click on the "All" node, and choose "Run as" -> "Ant build" (note: not
the line with three dots after "Ant build").
=== DEMO OUTPUT
Buildfile: C:\Documents and Settings\TRA\Workspaces\MyEclipse 6.5 -
Pulse Edition\slfj4-instrumentation-helloworld\build.xml
compile:
[delete] Deleting directory C:\Documents and
Settings\TRA\Workspaces\MyEclipse 6.5 - Pulse
Edition\slfj4-instrumentation-helloworld\output
[mkdir] Created dir: C:\Documents and
Settings\TRA\Workspaces\MyEclipse 6.5 - Pulse
Edition\slfj4-instrumentation-helloworld\output
[javac] Compiling 1 source file to C:\Documents and
Settings\TRA\Workspaces\MyEclipse 6.5 - Pulse
Edition\slfj4-instrumentation-helloworld\output
withoutAgent:
[java] Hello World - through println
[java] 22:36:55.125 [main] INFO demo.HelloWorld - Hello World -
through slf4j
withAgent:
[java] Start at Thu Aug 28 22:36:55 CEST 2008
[java] org.slf4j.LoggerFactory.getLogger(demo.HelloWorld.class);
[java] 22:36:55.468 [main] INFO demo.HelloWorld - >> main(args=[])
[java] Hello World - through println
[java] 22:36:55.468 [main] INFO demo.HelloWorld - >>
class$(x1=demo.HelloWorld)
[java] 22:36:55.468 [main] INFO demo.HelloWorld - <<
class$(x1=demo.HelloWorld) returns: class demo.HelloWorld
[java] 22:36:55.468 [main] INFO demo.HelloWorld - Hello World -
through slf4j
[java] 22:36:55.468 [main] INFO demo.HelloWorld - << main(args=[])
[java] Stop at Thu Aug 28 22:36:55 CEST 2008, execution time = 187 ms
all:
BUILD SUCCESSFUL
Total time: 2 seconds
===
That's it :)
Note the "class$" invocation in the output. It doesn't show when I run
the program directly from Eclipse. Wonder why :)
Comments are very welcome. Ceki, perhaps you could open a sandbox
corner for me in SVN? Makes it easier to share code...
--
Thorbjørn Ravn Andersen "... plus... Tubular Bells!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slf4j-agent-projects.zip
Type: application/octet-stream
Size: 759490 bytes
Desc: not available
URL: <http://qos.ch/pipermail/slf4j-dev/attachments/20080828/e1eb1dfb/attachment.obj>
More information about the slf4j-dev
mailing list