Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

WebServlet 3 with log4j2 threaded logging  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Been a lurker for a while, so this is my first time to say 'hi'.

I've come across a really 'stubborn' problem i can't resolve.

I'm building a webservlet 3 app with hibernate on jdk 8 with apache tomee 1.7.4.

The problem i have come across came up i tried to implement logging for a specific functionality.
The functionality requires me to create a log for each user where the write path for the log is determined by the username (obtained from the active user session).
I've reviewed a ton of documentation & implementation for the common logging libs for java.

The common problem for all different implementations, however, is that whenever user1) and user2) have to both log an event at the exact same time,
the messages maintain to be unique for them, but the path is not preserved, so for example the message for /opt/weblog/user1/web.log goes to
/opt/weblog/user2/web.log instead.
Having this said, imagine what happens with 50 users.

I've been trying to solve this in so many different ways, im not sure i can even list them all.

Right now what im doing some something like:

Conf(looks like this for debugging purposes & definitely is not the final version):

By documentation, the async appender shown as an example here:
works incredibly slowly & the api has been changed since the docs were last updated, so effectively the shown implementation is not possible in log4j2 2.11.

Can anyone demonstrate an implementation with any logging lib, where this issue does not happen, or just maybe explain whats wrong with this one?
Posts: 1845
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know if you are still encountering this problem, but have you looked at using LogBack?
They seem to have a solution for this: covers this exact use case.

brevity is the soul of wit - shakepeare. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!