This is the concern of the logging library, not PdfBox. Log4j2 has a solution for this: "Log4j – Log4j 2 Thread Context" https://logging.apache.org/log4j/2.x/manual/thread-context.html
I'm sure other logging libraries have something similar. We use this in all of our applications to segment logs between different customers. On Fri, Nov 26, 2021, 9:55 AM Bernhard Fey <bernhard....@realobjects.com> wrote: > Hello, > > Thank you, but we only found ways to globally configure logging for the > entire Java environment. To elaborate on the context: > Our use case is that our customers use our library in their Java > environment to create PDFs and optionally merge them with existing PDFs. > The latter is being migrated to use PDFBox. > Logging in our library is handled by a separate Java logger instance for > each conversion. Multiple conversions can be executed at the same time, in > different threads. > Our goal is to forward the log output of each PDFBox operation to the > logger of the conversion that invoked it. > However, as we are shipping a library, to be used in an arbitrary Java > environment, we cannot do any configuration that affects the entire > environment, e.g. all Commons Logging loggers or all loggers used by PDFBox > no matter if executed by our library or another one. > > Thanks in advance. > > Bernhard Fey > Product Development > Team Martha > - - - - - - - - - - - - - - - - > RealObjects GmbH > Altenkesseler Str. 17/B6 > 66115 Saarbrücken, Germany > Tel +49 (0)681 98579 0 > Fax +49 (0)681 98579 29 > http://www.realobjects.com > bernhard....@realobjects.com > - - - - - - - - - - - - - - - - > Commercial Register: Amtsgericht Saarbrücken, HRB 12016 > Managing Directors: Michael Jung, Markus Neurohr > VAT-ID: DE210373115 > > > > -----Original Message----- > From: Tilman Hausherr <thaush...@t-online.de> > Sent: Donnerstag, 25. November 2021 20:13 > To: users@pdfbox.apache.org > Subject: Re: Managing logging > > Use and configure your favorite logger, e.g. log4j 2. > > Tilman > > Am 25.11.2021 um 14:50 schrieb Bernhard Fey: > > Hello, > > > > We are in the process of integrating PDFBox into our PDF library, so we > can use it to merge or encrypt the PDFs we create. This works very well, > but we have one remaining issue: > > By default PDFBox logs to stderr. To change that it seems we have to > change the Commons Logging configuration which will affect every usage of > PDFBox as well as everything else that uses Commons Logging in the same VM. > > So, if our library is used by a customer that also uses other > > libraries that use Commons Logging in the same VM, we need a way to > configure the logging of PDFBox without affecting other libraries used by > that customer that also use Commons Logging. > > In the worst case the customer also has PDFBox as a (transitive) > dependency. In this case we'd require to configure the logging of our calls > to PDFBox independently of any other ones. > > Additionally it would be nice if we could attribute the log messages > from our usage of PDFBox to the specific caller, but we should be able to > implement that ourselves, if we can solve the rest. > > > > Thanks in advance. > > > > Bernhard Fey > > Product Development > > Team Martha > > - - - - - - - - - - - - - - - - > > RealObjects GmbH > > Altenkesseler Str. 17/B6 > > 66115 Saarbrücken, Germany > > Tel +49 (0)681 98579 0 > > Fax +49 (0)681 98579 29 > > http://www.realobjects.com<http://www.realobjects.com/> > > bernhard....@realobjects.com<mailto:bernhard....@realobjects.com> > > - - - - - - - - - - - - - - - - > > Commercial Register: Amtsgericht Saarbrücken, HRB 12016 Managing > > Directors: Michael Jung, Markus Neurohr > > VAT-ID: DE210373115 > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >