I got the idea from https://github.com/outr/scribe, and I wanted to adapt
it for log4j. Basically the idea is that I'd create a wrapper for Loggers
that provides information from the compiler for source code.

See
https://github.com/outr/scribe/blob/master/shared/src/main/scala/scribe/Macros.scala#L35
for one example of how this can work. It's a bit dense, but basically you
can see that there's a context, and it's used to generate some logging code
that includes the class name, method name, and line number. Something
similar could help Log4j skip any reflection or stack analysis it would use
to get the same information.

On Sat, Dec 9, 2017 at 2:31 AM, Remko Popma <[email protected]> wrote:

> Interesting!
> Can you point to an example of how this works? I’m trying to understand
> what changes would be required.
>
> Remko
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
> > On Dec 9, 2017, at 15:30, Jeffrey Shaw <[email protected]> wrote:
> >
> > Hello,
> > I've found that I am able to use Scala macros to provide compile-time
> > source information for log messages. However, I don't see a way to inject
> > this into log4j's logging mechanism.
> >
> > I'm wondering if there is something I'm missing, or if LogEvent's
> getSource
> > method could be duplicated in Message.
> >
> > We could then have zero-overhead location information in logs. I'm
> thinking
> > that tools other than Scala could also take advantage of this.
> >
> > Thanks,
> > Jeff
>

Reply via email to