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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:47:09+00:00 2026-06-08T03:47:09+00:00

I am using spring to inject a class into my PropertyDefiner implementation which will

  • 0

I am using spring to inject a class into my PropertyDefiner implementation which will be used to help set up some properties within the logback.xml file (through dynamic property loading).

I’d love to get this class loaded and instantiated before logback is configured. Any thoughts on how to do this?

  • 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-08T03:47:11+00:00Added an answer on June 8, 2026 at 3:47 am

    My solution resulted in not implementing a PropertyDefiner. The original question became an issue of not having the application context from spring to set the dynamic properties. I’m not sure why, but code in a later listener (after the Spring listeners) would get called (invoking the LoggerFactory call) before the application context was available. I tried a number of things, until I starting looking at a different approach.

    Instead of using dynamic properties I created a listener (called on server startup) which then programmatically sets up my appender with the properties I want (through the createAdminNotifyAppender).

    @Override
    public void contextInitialized(ServletContextEvent arg0)
    {
        //Set up the property reader to pull the correct properties
        ServletContext context = arg0.getServletContext();
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(context);
        propReader = (AppConfigPropertiesReader)appContext.getBean("propertySourcesPlaceholder");
    
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    
        createAdminNotifyAppender(lc, propReader);
    }
    

    The createAdminNotify method simply sets up an appender and adds it to the logging context. (if you’re really interested, you can see that method’s implementation on this thread).

    Now I have a separate and modular listener that I can add to other apps that are using logback, but possibly with different properties. The properties are pulled from a database and can also vary by environment.

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

Sidebar

Related Questions

I'm using Spring 3 and want to inject some dependencies into a class that
I'm using spring with my application, and I'm able to inject some properties from
I'm trying to inject Spring beans into an EJB using @Interceptors(SpringBeanAutowiringInterceptor.class) but I cannot
I am using Spring to inject beans. And I am using some annotations to
I'm trying to use Spring to inject a SLF4J logger into a class like
I'm using StructureMap to inject a LINQ data context ( DB class) into my
I'm trying to inject spring bean into JSF bean, I'm using Spring 3.1 and
Hi I am using spring jdbctemplate to invoke an oracle function which takes an
I'm using Spring 3.1.0.RELEASE with Spring Security 3.1. I want to inject my Spring
I want to dependency inject an attribute in ASP.NET MVC using Spring.Net, my attribute

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.