The problem is with the toConsole(). I've removed it and now I get only one
output (I'm logging at debug level). I've modified my logback.xml so the
console definition is in the file.
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>====> %msg%n</pattern>
</encoder>
</appender>
<root>
<level value="error" />
<appender-ref ref="Console"/>
</root>
</configuration>
Removed the .toConsole(),
LogFixtureBuilder logBuilder = LogFixture.builder()
// Log to the console for debugging convenience
.logger("org.apache.drill.exec.store.msgpack", Level.DEBUG);
try (LogFixture logs = logBuilder.build()) {
Also another issue I was having is that I was getting 3 outputs initially.
I was picking up this logback file because logback tries to load
logback-test.xml before logback.xml.
https://github.com/apache/drill/blob/7b0c9034753a8c5035fd1c0f1f84a37b376e6748/common/src/test/resources/logback-test.xml
Should I be using a logback-text.xml in my personal project or should that
common logback-test.xml be removed ?
Thanks Paul
jc
On Sat, Nov 3, 2018 at 3:39 PM Paul Rogers <[email protected]>
wrote:
> Hi JC,
>
> Your code looks fine. I usually start with the default log level (ERROR),
> then turn on DEBUG for specific modules, as you do. I then see my INFO or
> DEBUG messages. My code looks like yours, so I'm not sure why you are
> seeing two messages. Perhaps you are logging ERROR level messages?
>
> If you look at the LogFixture code, you'll see that it works by creating a
> new console appender, then enabling only the logging you request. This
> works if the default appender logs only errors and you want to see INFO or
> DEBUG. I suppose it might cause double reporting if you log ERROR messages.
>
> All this leads to a suggestion: if you want to visualize ERROR messages,
> you have two choices. First, don't use the LogFixture since the default
> logging already does what you want. Second, perhaps modify your default
> file has to turn off console logging completely, so that only the
> LogFixture controls the console.
>
> Thanks,
> - Paul
>
>
>
> On Saturday, November 3, 2018, 12:17:28 PM PDT, Jean-Claude Cote <
> [email protected]> wrote:
>
> I'm using the LogFixture
>
> LogFixtureBuilder logBuilder = LogFixture.builder()
> // Log to the console for debugging convenience
> .toConsole().logger("org.apache.drill.exec.store.msgpack", Level.DEBUG);
> try (LogFixture logs = logBuilder.build()) {
>
>
> Basice logback.xml file is
>
> <configuration>
>
> <root>
> <level value="error" />
> </root>
>
> </configuration>
>
>
> However when I do so I get two outputs. The LogFixtureBuilder seems to
> install the appender twice. When I step into the logback code I saw that
> the appender was found on "org.apache.drill" and on the ROOT Logger. Which
> is why I get two outputs.
>
> I'm using the API correctly?
> thanks
> jc
>