--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
I'm using the J2SE backend to SLF4J, and this information is not available in the correct fields.
My custom formatter allows me to do something similar to logback's formatter
http://code.google.com/p/zibaldone/source/browse/fommil.zibaldone/src/main/java/uk/me/fommil/logging/CustomFormatter.java
I can assure you that LogRecord.getSourceClassName() is pointing to the Akka SLF4J interface [Slf4jEventHandler$$anonfun$receive$1$$anonfun$applyOrElse$3.apply$mcV$sp]
The default J2SE "Handler" uses class based "level" statements to filter the output. Since everything in Akka is coming from the SLF4J interface class, this means I can't do filtering.
Furthermore, no matter what your backend is – there are still messages being printed directly to stdout by Akka Logging.
I'm seriously considering writing a very thin layer to do my own asynchronous J2SE Logging. I'm hesitant to do this because it means it will only work for my Actors, and not those already defined in Akka.
If I were able to register a callback on the "unhandled" messages, it might be all I need.
On 30 Nov 2012, at 19:52, Alec Zorab wrote:I'm using the J2SE backend of SLF4J, so I don't even see the MDC.
> Sam - the extra information is inside the mdc. Are you saying that you don't see the relevant information in there?
As background for those who do not know the Java Logging API: the core customisable elements of J2SE Logging are the Handler and the Formatter. I find the default Handler to be sufficient for most situations, but the default Formatter is ugly as sin (it manages to be verbose whilst also avoiding giving detail – the perfect politician!).
Both the Handler and the Formatter accept LogRecord instances. Given a published LogRecord, one can read off:
* message
* log level
* name of the logger
* a timestamp
* source method name
* source class name
* Thread ID (not it's name, sadly)
(which is what my Formatter does)
But the Akka Logger is not setting the classname/method correctly and I have no way to check if the Thread ID is correct without further empirical study. It's probably constructing SLF4J's equivalent of the LogRecord in a Future.
Assuming that the classname issue is a bug with Akka – and is fixed shortly – I would like to have the option to specify the name format given to the Logger: I want to use the Actor's name.
I would also like to know if, by using this SLF4J interface, are my logs still asynchronous? (e.g. will log.info("message") return instantly?)
Is it not a good idea to have the logging independent of the Actor system itself?
--
Sam
History getting too big, follow it at: https://groups.google.com/d/topic/akka-user/S1bwDHbju94/discussion
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
Thanks Victor,
I can, of course, write my own handlers and adapters for this – but I would rather not have to resort to such things. I am first trying to solve the problem with existing tools. It pained me greatly to have to write my own J2SE Formatter, and I'll be damned if I have to do it again for Akka.
I will submit an issue with the tracker as you have suggested, regarding the classname. I will try to see if the thread ID is broken within the same test.
Thanks for the heads up on Logging.apply, if we can fix the bug I'm about to submit, then I will probably create my own trait to replace ActorLogging.
--
Sam
On 30 Nov 2012, at 22:09, √iktor Ҡlang <viktor...@gmail.com> wrote:
> … use your own EventHandler/LoggingAdapter and customize it to your needs.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
On Fri, Nov 30, 2012 at 11:22 PM, Samuel Halliday <sam.ha...@gmail.com> wrote:
Thanks Victor,You're most welcome!
I can, of course, write my own handlers and adapters for this – but I would rather not have to resort to such things. I am first trying to solve the problem with existing tools. It pained me greatly to have to write my own J2SE Formatter, and I'll be damned if I have to do it again for Akka.
Well, since you have decided to use a non-default approach it normally entails some customization, right? We do not see the value proposition or performance of j.u.l so we focused on making something performant, asynchronous that was extensible/customizable with a sane default.
Hi Sam,
I believe I have already answered that quedtion in the previous emails.
Cheers,
V
Alec, Victor,
I have gone into the details of SLF4J and concluded that the bug cannot be fixed directly. Akka using SLF4J with j.u.l incorrectly logs the originating source classes, methods and threads.
I'll detail this below, but I think it is safe to say that you should warn developers against using akka-slf4j with a j.u.l backend.
As a workaround, I will contribute an appropriate LoggingAdapter that talks directly to j.u.l.
Watch out for a pull request on github – I hope you are willing to accept it. I will try to also write a "clean" trait to abstract away the j.u.l Logger API, just for Victor ;-)
Details...
SLF4J uses a class named JDK14LoggerAdapter to implement logging with j.u.l. This does several things that are universal quirks of placing another logging layer on top of SLF4J, and cannot be fixed:
1. The Thread ID field is set to the thread that is executing inside JDK14LoggerAdapter: the threadName passed by Akka is ignored. If Akka has launched the logging process in a new Thread, then this field will not match the source.
2. JDK14LoggerAdapter.fillCallerData finds the last non-SLF4J FQCN in the calling stack: the Slf4jEventHandler anonymous class. Any Akka info about the sourceClass (or method) is therefore ignored.
On Dec 1, 2012 5:10 PM, "Samuel Halliday" <sam.ha...@gmail.com> wrote:
>
> Victor,
>
> Yes: the bug is in putting another logging layer above SLF4J – it has not been designed to handle this. To fix it would involve a significant rewrite of the SLF4J JDK14 backend.
It works perfectly fine with logback, so I don't think it's a bug in slf4j. As I've said countless times, you can implement whatever you like with your own LoggingAdapter + EventHandler.
Cheers,
V
Dear All,
(especially Victor and Alec)
I have implemented JavaLogging and Specs as originally suggested.
I have created a pull request with the justification for why I feel this is a useful addition to the project:
https://github.com/akka/akka/pull/913
Victor, it's now up to you whether you feel this is something that would benefit other users.
Here is a direct link to the implementation and spec
https://github.com/fommil/akka/blob/master/akka-contrib/src/main/scala/akka/contrib/jul/JulEventHandler.scala
https://github.com/fommil/akka/blob/master/akka-contrib/src/test/scala/akka/contrib/jul/JulEventHandlerSpec.scala
--
Sam
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.