Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9073709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:28:46+00:00 2026-06-16T18:28:46+00:00

I use sl4j-api 1.7.2 with slf4j-log4j12. I would like to log something like this:

  • 0

I use sl4j-api 1.7.2 with slf4j-log4j12.

I would like to log something like this:

22:52:27,345 WARN [class] Failed to load user 1 – Reason :
javax.ejb.EJBException: javax.persistence.NoResultException: No entity
found for query at
org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
[jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final] at
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
[jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final] at
org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
[jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
… fullstackTrace

So I tried

try {
            //...
        } catch (Exception e) {
            logger.warn("Failed to load User {} - Reason : {}", userId, e);
        }

Or

try {
               // ...
            } catch (Exception e) {
                logger.warn("Failed to load User {} - Reason : ", userId, e);
            }

But none of this two solutions work

The first try give :

Failed to load User 4 – Reason : javax.ejb.EJBException:
javax.persistence.NoResultException: No entity found for query

The second :

Failed to load User 4 - Reason :

Is it possible to made it ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:28:49+00:00Added an answer on June 16, 2026 at 6:28 pm

    Check the Logger API and the SL4J FAQ. You are probably using a SL4J version prior to 1.6.0 in which e will be interpreted as a simple object (i.e., SL4J will call e.toString()) if you have a parameter placeholder or ignored if you don’t.

    As for why it is using a version different than 1.7.2, a previous version is probably included in your Application Server Classpath and getting loaded before you even start your application.

    You can either try to fix the Classloading problem or workaround the old version behavior.

    If you choose the latter path, from the overloaded versions you need either the warn(String msg, Throwable t)) version that auto expands the stacktrace:

    logger.warn("Failed to load User " + userId + " - Reason",  e);
    

    Or the warn(String format, Object arg1, Object arg2) one with code that expands the stacktrace for you.

    if (logger.isWarnEnabled()) {
       StringWriter sw = new StringWriter();
       PrintWriter pw = new PrintWriter(sw);
       e.printStackTrace(pw);
       String expanded = sw.toString(); // stack trace as a string
       logger.warn("Failed to load User {} - Reason : {}", userId, expanded);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use trap to capture signals like this: i=-1;while((++i<33)); do trap echo $i >> log.txt
Use case: user types something like: AA1234↵ - i want the browser to directly
Use case is this: I want to unit test (in browser, QUnit or something
I use sl4j / logback as a logging framework. I am unsure about the
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
Use-case: A Xib is defined with a single simple UIView A custom view class
use strict; use Time::HiRes qw[gettimeofday tv_interval]; my $start_index = int(rand(50))+100;#this value is arbitrary for
Use Memcache php class to interact with the memcached. At the beginning all works
Use Html element SELECT in aspx page like: <SELECT id=MySelection name=MySelection runat=server DataValueField=ID DataTextField=Name></SELECT>
use DBI(); What is causing this insert to fail to err 1, the SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.