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

  • Home
  • SEARCH
  • 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 8156739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:03:13+00:00 2026-06-06T17:03:13+00:00

In my logging messages, I need to insert the name of the method where

  • 0

In my logging messages, I need to insert the name of the method where the messages were produced. I’ve looked at Log4J documentation and “M” and “l” conversion chars that also have warning like “WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue”. So I have (at least) two options:

  1. Use these chars but slow down my code
  2. Manually insert method name into messages, i.e. something like this log.info("myMethod: message"); which will be faster but not as elegant

Are there any other options that would not slow down my code?

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-06T17:03:15+00:00Added an answer on June 6, 2026 at 5:03 pm

    I am not sure of the IDE that you are using, but if you are using Eclipse based IDE’s you should be able to use some Java templates. This will still be using the method names as strings,but will save you typing time.

    I created a whole set of templates like this:

    • Template name – li
    • Pattern – logger.info("${cursor}");

    and so on for warn, error, and debug.

    For start and end of method, or just to add method name to every log out – use something like:

    • Template name – lie
    • Pattern – logger.info("End: ${enclosing_method}${cursor}");

    and so on.

    The only constraint is your logger ref variable will always have to be named logger.
    Now you will just need to type lie and (optionally hit ctrl+space if you uncheck the Automatically Insert checkbox at template creation time.)

    HTH!

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

Sidebar

Related Questions

I want to configure my log4j logging to not log messages that are 1)
I have a C++ application and a Java application that need to log messages
In the Python docs I found that logging messages are possible in python scripts
I have scripts which print out messages by the logging system or sometimes print
In settings.py I have setup a way to log my messages like this: logging.basicConfig(
I need to parse a logfiles that contains FIX protocol messages. Each line contains
I need to design a thread-safe logger. My logger must have a Log() method
I am penning down the features that a remote logging library might need when
I have the logging module MemoryHandler set up to queue debug and error messages
I have some scripts that I need to run that I want to access

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.