in the last example box in the previous section we have sent logging records to the 'libro.romanzo.campanile' logger. we have done this by invoking the global loginfo function, passing it the name of the logger. this is only practical if you are logging to the root logger or if you are using many different loggers, not if you are sending, as in our example, more records to the same logger. if you are talking the whole time to the same logger, you do not want to have to repeat the name of the logger each time you send it a record.
the solution to this is in the object oriented approach taken in
this logging library. the getLogger() function returns a Logger
object, which, since we are using Reference Classes, is itself an
environment. in the previous examples we have only used the fact that
Logger objects are environments, let's now have a look at what more
they offer.
>
[1] "Logger"
attr(,"package")
[1] "logging"
>
[1] TRUE
>
let me keep it compact, I'm just giving you the code that will
produce the same logging as in the previous example. do notice that
you can mix invoking object methods with usage of the global
functions.
R>
R>
R>
R>
2010-04-08 11:18:59 INFO:libro.romanzo.campanile:Ma cos'è questo amore?
R>
2010-04-08 11:19:05 INFO:libro.romanzo.campanile:Se la luna mi porta fortuna
R>
2010-04-08 11:19:12 INFO:libro.romanzo.campanile:Giovanotti, non esageriamo!
R>
2010-04-08 11:22:06 INFO:libro.romanzo.lessing:memories of a survivor
R>
R>
R>