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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:07:16+00:00 2026-06-14T02:07:16+00:00

I am creating an admin page which has a couple of logback properties that

  • 0

I am creating an admin page which has a couple of logback properties that I want to set on the fly, one of them being the admin emails that I send system alerts to. The api for the SMTPAppender has the methods to add to the list of “to” addresses, or get them as a list, but I didn’t find anything to clear, remove any or update them. How should I do this?

I see two options currently:

  1. One option is to remove the appender and create a new one with the new properties (yuck).
  2. Figure out how to configure this directly through Joran (maybe yuck?).

I’m moving forward with (2), but please post if there’s a better way.

  • 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-14T02:07:17+00:00Added an answer on June 14, 2026 at 2:07 am

    Maybe you’re done with this, but I just needed to find a way to set dynamic “to” addresses, and this topic lead me to the way (thanks to @gresdiplitude idea on system properties and MDC values), so I’m sharing my solution.

    I am using SMTPAppender to send small execution reports, but those need to be sent to different mailboxes. The solution looks yuck-less, or at least I got very pleased with the result.

    My logback.xml:

    <!-- this is the trick: a converter to use on the "to" field pattern -->
    <conversionRule conversionWord="smtpTo" converterClass="com.example.logback.MyConverter" />
    <appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
        <!-- a filter to select just the log entries that will be sent by mail -->
        <filter class="com.example.logback.MyFilter" />
        <!-- an evaluator, mine is like CounterBasedEvaluator from the manual:
            http://logback.qos.ch/xref/chapters/appenders/mail/CounterBasedEvaluator.html
        -->
        <evaluator class="com.example.logback.MyEvaluator">
            <limit>25</limit>
        </evaluator>
        <!-- a discriminator to create a cyclic buffer for each mailing group I need -->
        <discriminator class="com.example.logback.MyDiscriminator" />
        <!-- just matching buffer size to evaluator limit -->
        <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTrackerImpl">
            <bufferSize>25</bufferSize>
        </cyclicBufferTracker>
        <smtpHost>${smtp.host}</smtpHost>
        <smtpPort>${smtp.port}</smtpPort>
        <SSL>${smtp.ssl}</SSL>
        <username>${smtp.username}</username>
        <password>${smtp.password}</password>
        <from>${smtp.from}</from>
    
        <!-- here you use the converter: in this case will get data
            from marker containing the destination addresses
        -->
        <to>%smtpTo</to>
        <subject>my subject</subject>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date: %message%n%xThrowable{full}</pattern>
        </layout>
    </appender>
    

    MyFilter.java:

    public FilterReply decide(ILoggingEvent event) {
        return event.getMarker() != null
                && event.getMarker().contains("REPORT") ? FilterReply.ACCEPT
                : FilterReply.DENY;
    }
    

    MyDiscriminator.java:

    public String getDiscriminatingValue(ILoggingEvent e) {
        Marker marker = e.getMarker();
        if (marker == null || !(marker instanceof MyMarker)) {
            return null;
        }
        return ((MyMarker) marker).getDiscriminatingValue();
    }
    

    MyConverter.java:

    public class MyConverter extends ClassicConverter {
    
        @Override
        public String convert(ILoggingEvent event) {
            Marker marker = event.getMarker();
            if (marker == null || !(marker instanceof MyMarker)) {
                return null;
            }
            return ((MyMarker) marker).getSmtpTo();
        }
    }
    

    MyMarker.java:

    public interface MyMarker extends Marker {
        // a list of destination addresses, like "a@c.com, x@y.net"
        String getSmtpTo();
        // an "id" to tell the buffers apart, could be "smtpTo" itself
        // but in my case it would mix different reports that goes to the same addresses
        String getDiscriminatingValue();
    }
    

    I just created an implementation for MyMarker, and used several instances of it on every logging statement that should be reported:

    // suggestion: make the marker immutable, then you can store and reuse them instead of recreating them every time
    Marker marker1 = new MyMarkerImpl(
        "REPORT", // marker name
        "me@company.com, joe@company.com", // smtpTo
        "alertGroup"); // discriminatingValue
    logger.warn(marker1, "SNAFU");
    Marker marker2 = new MyMarkerImpl(
        "REPORT", "boss@company.com, ceo@company.com", "phbGroup");
    logger.info(marker2, "Everything is fine");
    // here we have same smtpTo as above but different discriminatingValues, so this will be sent in another email/report
    Marker marker3 = new MyMarkerImpl(
        "REPORT", "me@company.com, joe@company.com", "bugFixingGroup");
    logger.error(marker3, "Why things gone bad", exception);
    

    Hope it can be useful.

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

Sidebar

Related Questions

When creating properties and page types through admin mode in EPiServer, it's quite easy
I'm creating an admin module for my client that gives them access to some
So I am creating a website that I want to have an admin directory
I'm creating an admin page that displays a list of user registrations pending approval.
I am creating one admin page where I have multiple textboxes.when I enter the
I am creating a master page for admin-side of my application, which is using
I'm thinking of creating a diagnostics page for an ASP.NET app, which would be
I`m an admin on a facebook fan page. The problem is that when I
I am creating page for admin to view all user in the system database.
I have modified the buddypress admin bar by creating the following plugin which adds

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.