Separate logging for JPMS module/layer
rgoers at apache.org
Wed Oct 3 16:26:20 UTC 2018
Log4j handles this by capturing the fully qualified class name of the logging adapter. Obviously, this doesn’t work if the adapter doesn’t pass Log4j the FQCN, but it does work for the adapters we support. That said, it is very slow to capture this and is probably the biggest pain point. Log4j recommends not capturing this information in production environments because it is so slow. Unfortunately, it seems to have gotten even slower in Java 9+. In an ideal world we would be able to capture the caller information at compile time but Java provides no good way to do this. Wouldn’t it be great if I could just code something like logger.error(_CallerInfo_, “hello”) and the compiler would provide the caller info data structure that was generated by the compiler?
FWIW, I do plan to add the module information to the caller information provided with Log4j but just haven’t gotten to it. You are more than welcome to provide a patch.
> On Oct 2, 2018, at 3:20 PM, Alex Sviridov <ooo_saturn7 at mail.ru> wrote:
> Thank you for you suggestion. But can this be used when some library
> uses one logging system and for another uses some bridge. Because of this bridging
> LoggerFactory.getLogger is called somewhere in bridge, as I understand,
>> Среда, 3 октября 2018, 1:12 +03:00 от Remi Forax <forax at univ-mlv.fr>:
>> You can use the StackWalker
>> ----- Mail original -----
>>> De: "Alex Sviridov" < ooo_saturn7 at mail.ru >
>>> À: "jigsaw-dev" < jigsaw-dev at openjdk.java.net >
>>> Envoyé: Mardi 2 Octobre 2018 23:54:48
>>> Objet: Separate logging for JPMS module/layer
>>> Hi all,
>>> Could anyone say how the following problem can be solved. I want to create
>>> log file for every JPMS module/layer. The problem is that many
>>> use LoggerFactory.getLogger(String className) so in getLogger I have only
>>> the name of the class as String, so I can't get module and layer.
>>> If I had not String className, but Class klass then the problem would be easily
>>> As I understand I can't load class by name because it would require all modules
>>> their packages to logging framework that has no sense.
>>> Are there any solutions for such problem?
>>> Alex Sviridov
> Alex Sviridov
More information about the jigsaw-dev