Is it possible, to configure Logging so that log4j messages from other modules, (like Hibernate) are shown directly in the Designer Runtime Log?

asked 02.10.2018 at 04:21

peters's gravatar image

accept rate: 0%

Hi Peter

You could use the following Utility class to forward log message from one Logger to another one. E.e. from the Hibernate Logger to the Runtime Log (ivy.log)

import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Priority;
import org.apache.log4j.spi.LoggingEvent;

import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.log.Logger;

public class LogUtil
    private static class ForwardAppender extends AppenderSkeleton 
        public static final String NAME = ForwardAppender.class.getSimpleName();
        private Logger to;

        public ForwardAppender(Logger to) {
   = to;

        public void close() {

        public boolean requiresLayout() {
            return false;

        protected void append(LoggingEvent event) {
            if (event.getThrowableInformation() != null)
                to.log(event.getLevel(), event.getMessage(), event.getThrowableInformation().getThrowable());
                to.log(event.getLevel(), event.getMessage());

    public static void forwardLoggerToLogger(Logger from, Logger to)
        if (from.getAppender(ForwardAppender.NAME)==null)
            from.addAppender(new ForwardAppender(to));

    public static void main(String[] args) 
        // Example 
        Logger hibernate = Logger.getLogger("org.hibernate");
        Logger runtimeLog = Ivy.log();
        forwardLoggerToLogger(hibernate, runtimeLog);

answered 02.10.2018 at 09:38

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
accept rate: 74%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 02.10.2018 at 04:21

Seen: 1,827 times

Last updated: 02.10.2018 at 09:38