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 9171761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:12:26+00:00 2026-06-17T16:12:26+00:00

can you give me please a step by step procedure to follow, in order

  • 0

can you give me please a step by step procedure to follow, in order to make log4j work on an ejb module?
the situation is this: i have my ejbmodule, which is using hibernate to perform some fetching tasks, and i want to log everything. I want to use log4j but i can not understand some steps of the others procedure described on the web like those from jboss.

Can you please tell me what i should do, step by step?

As far as i am:

  • I have got my configuration file (and i don’t know where to put it)

  • I have got the log4j.jar (and i don’t know where to place it)

  • I don’t know how to initialize the log environment (i have an ejb session bean which on startup initializes hibernate, i would like one to initialize the logger)

Can anyone of you help me please?

Thanks in advance

EDIT:
thanks for the fist suggestion it might help but i don’t undestand how others may have META-INF in the ear.
My project looks like 3 projects togheder:

  • MyprojectLogic (which contains the ejbmodules)
  • MyprojectLogicClient (which contains all the interfaces, it is the library to be given to the client)
  • MyprojectLogicEAR (which actually contains nothing, i did not get what is its purpose)

ANSWER: see below or check here javafortheweb or blog

  • 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-17T16:12:27+00:00Added an answer on June 17, 2026 at 4:12 pm

    Jboss already comes with log4j.
    When developing your EJB you need to:

    1. import the Logger class: import org.apache.log4j.Logger;
    2. If the import does not resolve, add this jar to the path: %JBOSS_HOME%\modules\org\apache\log4j\main\log4j-1.2.16.jar
    3. create a field with the logger: private static Logger logger = Logger.getLogger(YourEJBClass.class);
    4. use the logger in any method: logger.info("my log");

    JBoss already comes with a configuration file under %JBOSS_FOLDER%/standalone/configuration/standalone.xml. By default, your logger will output to server.log and console, but you can add some appender to output your app logs to another file.

    Here is an example, edit that file and add the following snippets (following the definition of the file):

    • this one is to add an appender to the file myappfile.log inside the logs folder (add this right after the already defined under name=”FILE”):
    <periodic-rotating-file-handler name="FILETWO">
      <formatter>
        <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
      </formatter>
      <file relative-to="jboss.server.log.dir" path="myappfile.log"/>
      <suffix value=".yyyy-MM-dd"/>
      <append value="true"/>
    </periodic-rotating-file-handler>
    
    • add this snippet tells log4j to send all logs from “com.mypackage” category to the previously created appender (copy this right after other defined logger in the file, but before the root-logger):
    <logger category="com.mypackage">
        <level name="DEBUG"/>
        <handlers>
            <handler name="CONSOLE"/>
            <handler name="FILETWO"/>
        </handlers>
    </logger>
    

    Restart the server and you should see the new myappfile.log in the folder. Make sure your app logs something, for example, adding logger.info(“my servlet info log”) in some servlet and call it from the browser. You’ll also see this log in the console

    If you need further customization, have a look at log4j help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody give me a little advice please? I have a string, for example
Can someone give me a simple example involving threads in this manner, please. Problem
Can someone please give me a step by step on how to build an
Can you please give me Resources(Books, Tutorials, Other useful links ) to learn QT/Embedded
can someone please give me an example on the internet of how the system
Can you please give me some comparison between C compilers especially with respect to
Can someone please give me an idea of how the WIRED Magazine on iPad
Friends, Can you please give me significance, difference and uses for Heap and PermGen.
It does not matter what programming language. Can anyone please give me an idea
What is the difference? Are these the same? If not, can someone please give

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.