librelist archives

« back to archive

Logger

Logger

From:
John Freeman
Date:
2013-05-03 @ 19:15
Continuing the conversation from
https://bitbucket.org/aragost/javahg/issue/35/inspect-logs-turn-on-logging

Looking through the code, everything interacts with
a com.aragost.javahg.log.Logger which does not interact with
java.util.logging.Logger or the log4j extensions to that class. It doesn't
appear that the linked example [1] will catch any logs, and it doesn't in
my test. How can I get javahg's logs?

[1]

https://bitbucket.org/mercurialeclipse/main/src/f948216f140bbda79f835b912642d7f92d4e366d/plugin/src/com/vectrace/MercurialEclipse/views/console/HgConsoleHolder.java?at=default#cl-141

Thanks,
John

Re: [javahg] Logger

From:
John Peberdy
Date:
2013-05-03 @ 19:40
Hi John,

Good questions. There's not really documentation on the logging
infrastructure.

You're right that logging is done through com.aragost.javahg.log.Logger and
not java.util.logging.Logger directly. However by default the logger that
is instantiated is a java.util.logging.Logger. See the logic in
com.aragost.javahg.log.LoggerFactory - the default behavior is to use
java.util.logging.Logger (JULLoggerFactory).

It is possible to use a different log implementation either:
- Set the system property: com.aragost.javahg.log.LoggerFactory to a class
name
- Use java.util.ServiceLoader style configuration
In either case you would implement com.aragost.javahg.log.LoggerFactory

If you use the default implementation: java.util.logging can log to stdout
- it is probably possible to log to other outputs too, try google. Though
the simplest is probably to do what MercurialEclipse does as already linked.






On Fri, May 3, 2013 at 3:15 PM, John Freeman <jfreeman08@gmail.com> wrote:

> Continuing the conversation from
> https://bitbucket.org/aragost/javahg/issue/35/inspect-logs-turn-on-logging
>
> Looking through the code, everything interacts with
> a com.aragost.javahg.log.Logger which does not interact with
> java.util.logging.Logger or the log4j extensions to that class. It doesn't
> appear that the linked example [1] will catch any logs, and it doesn't in
> my test. How can I get javahg's logs?
>
> [1]
> 
https://bitbucket.org/mercurialeclipse/main/src/f948216f140bbda79f835b912642d7f92d4e366d/plugin/src/com/vectrace/MercurialEclipse/views/console/HgConsoleHolder.java?at=default#cl-141
>
> Thanks,
> John
>



-- 
John Peberdy

Re: [javahg] Logger

From:
John Freeman
Date:
2013-05-03 @ 20:02
Let me see if I understand:

(1) java.util.logging.Logger already has all the facilities to redirect
logs, and
(2) without any configuration, the com.aragost.javahg.log.Logger returned
by com.aragost.javahg.log.LoggerFactory is a
com.aragost.javahg.log.JULLogger that wraps a java.util.logging.Logger.

So what I really need is to get to that wrapped java.util.logging.Logger
and use the wonderful facilities it provides, but there is no getter for
it, so my options are either

(1) to edit your library or
(2) to implement both my own com.aragost.javahg.log.LoggerFactory *and*
com.aragost.javahg.log.Logger to do what is already done (wrap a
java.util.logging.Logger) but also expose the underlying
java.util.logging.Logger?

Is that correct?

Thank you,
John

Re: [javahg] Logger

From:
John Peberdy
Date:
2013-05-03 @ 20:07
On Fri, May 3, 2013 at 4:02 PM, John Freeman <jfreeman08@gmail.com> wrote:

> Let me see if I understand:
>
> (1) java.util.logging.Logger already has all the facilities to redirect
> logs, and
> (2) without any configuration, the com.aragost.javahg.log.Logger returned
> by com.aragost.javahg.log.LoggerFactory is a
> com.aragost.javahg.log.JULLogger that wraps a java.util.logging.Logger.
>
>
Correct


> So what I really need is to get to that wrapped java.util.logging.Logger
> and use the wonderful facilities it provides, but there is no getter for
> it, so my options are either
>
> (1) to edit your library or
> (2) to implement both my own com.aragost.javahg.log.LoggerFactory *and*
> com.aragost.javahg.log.Logger to do what is already done (wrap a
> java.util.logging.Logger) but also expose the underlying
> java.util.logging.Logger?
>
> Is that correct?
>
>
No, you can use the static method on java.util.logging.Logger to access the
same logger instance, like MercurialEclipse does.





> Thank you,
> John
>



-- 
John Peberdy

Re: [javahg] Logger

From:
John Freeman
Date:
2013-05-03 @ 20:28
On Fri, May 3, 2013 at 4:07 PM, John Peberdy <johnpeb@gmail.com> wrote:
>
>
> No, you can use the static method on java.util.logging.Logger to access
> the same logger instance, like MercurialEclipse does.
>

Alright, these java.util.logging.Loggers are hierarchical, so all logging
should pass through the Logger named "com.aragost.javahg" correct? I get an
exception, pasted below, but the only method on my logging handler getting
called is `close`. Should I be expecting no logs?


java.lang.RuntimeException: abort: authorization failed

at com.aragost.javahg.internals.Server.execHgCommand(Server.java:524)
at
com.aragost.javahg.internals.Server.cloneMercurialRepository(Server.java:514)
at com.aragost.javahg.internals.ServerPool.<init>(ServerPool.java:93)
at com.aragost.javahg.BaseRepository.<init>(BaseRepository.java:56)
at com.aragost.javahg.Repository.clone(Repository.java:94)


- John

Re: [javahg] Logger

From:
John Peberdy
Date:
2013-05-04 @ 03:54
On Fri, May 3, 2013 at 4:28 PM, John Freeman <jfreeman08@gmail.com> wrote:

>
>
> On Fri, May 3, 2013 at 4:07 PM, John Peberdy <johnpeb@gmail.com> wrote:
>>
>>
>> No, you can use the static method on java.util.logging.Logger to access
>> the same logger instance, like MercurialEclipse does.
>>
>
> Alright, these java.util.logging.Loggers are hierarchical, so all logging
> should pass through the Logger named "com.aragost.javahg" correct? I get an
> exception, pasted below, but the only method on my logging handler getting
> called is `close`. Should I be expecting no logs?
>
>
> java.lang.RuntimeException: abort: authorization failed
>

Try run a successful command to see if it logs then.


>
> at com.aragost.javahg.internals.Server.execHgCommand(Server.java:524)
>  at
> com.aragost.javahg.internals.Server.cloneMercurialRepository(Server.java:514)
> at com.aragost.javahg.internals.ServerPool.<init>(ServerPool.java:93)
>  at com.aragost.javahg.BaseRepository.<init>(BaseRepository.java:56)
> at com.aragost.javahg.Repository.clone(Repository.java:94)
>
>
> - John
>



-- 
John Peberdy