# Nd4j logging bubbling up

**URL:** <https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742>\
**Category:** ND4J\
**Created:** [January 6, 2022, 7:37pm UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742 "2022-01-06T19:37:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wcneill](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/wcneill/32/559_2.png) [@wcneill](https://community.konduit.ai/u/wcneill)\
**Post date:** [January 6, 2022, 7:37pm UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/1 "2022-01-06T19:37:19Z")

</div>

I’m using log4j2 (2.16) and am trying to find a way to disable or filter the logging that occurs in ND4J from my own logging. While it is good info to know, I’d like to be able to turn it off and on:

```auto
[INFO]	2022-01-06T14:34:56,250	utils.Data Reading src/test/resources/cluster_type0.csv
[INFO]	2022-01-06T14:34:56,539	factory.Nd4jBackend Loaded [CpuBackend] backend
[INFO]	2022-01-06T14:34:57,271	nativeblas.NativeOpsHolder Number of threads used for linear algebra: 8
[INFO]	2022-01-06T14:34:57,272	nativecpu.CpuNDArrayFactory Binary level Generic x86 optimization level AVX/AVX2
[INFO]	2022-01-06T14:34:57,293	nativeblas.Nd4jBlas Number of threads used for OpenMP BLAS: 8
[INFO]	2022-01-06T14:34:57,304	executioner.DefaultOpExecutioner Backend used: [CPU]; OS: [Windows 10]
[INFO]	2022-01-06T14:34:57,304	executioner.DefaultOpExecutioner Cores: [16]; Memory: [14.1GB];
[INFO]	2022-01-06T14:34:57,304	executioner.DefaultOpExecutioner Blas vendor: [OPENBLAS]
[INFO]	2022-01-06T14:34:57,306	nativecpu.CpuBackend Backend build information:
 GCC: "10.3.0"
STD version: 201103L
DEFAULT_ENGINE: samediff::ENGINE_CPU
HAVE_FLATBUFFERS
HAVE_OPENBLAS

```

my log4j2.properties file looks like so:

```auto
name=LogProperties
status=warn

appender.console.type = Console
appender.console.name = consoleLogger
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%p]\t%d{ISO8601}\t%c{2}\t\t%m%n

appender.file.type = File
appender.file.name = fileLogger
appender.file.append = false
appender.file.fileName = dean.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %m%n

rootLogger.level = info
rootLogger.appenderRef.stdout.ref = consoleLogger
rootLogger.appenderRef.file.ref = fileLogger

```

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [January 6, 2022, 8:39pm UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/2 "2022-01-06T20:39:34Z")

</div>

I don’t really have a lot of experience with log4j, but in other logging systems you can specify the log level by class path, so if you want nd4j to shutup, you can probably tell it to use a less verbose log level for everything in `org.nd4j`.

---

<div class="post-metadata">

**Author:** ![partarstu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/partarstu/32/276_2.png) [@partarstu](https://community.konduit.ai/u/partarstu)\
**Post date:** [January 10, 2022, 9:02am UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/3 "2022-01-10T09:02:25Z")

</div>

Hi. Based on DL4J’s POM file I’d deduce that SLF4J is used for logging as a facade and Logback as the specific implementation. So the solution would be to create logback.xml file in the resources folder and set the logging level there. If however you want to use log4j, I’d suggest you use SLF4J as well and simply put the corresponding log4j dependency as the first one in your POM (or the corresponding build management framework’s file if you don’t use Maven). I’d also suggest to use the log4j’s version which is fully patched against log4Shell vulnerabilities.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [January 11, 2022, 7:35am UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/4 "2022-01-11T07:35:38Z")

</div>

@partarstu @wcneill this is correct. It depends on what part of the library you’re using though. I think the only place we specify logback is in tests or in the UI. Beyond that it just uses slf4j.

---

<div class="post-metadata">

**Author:** ![wcneill](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/wcneill/32/559_2.png) [@wcneill](https://community.konduit.ai/u/wcneill)\
**Post date:** [January 11, 2022, 4:55pm UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/5 "2022-01-11T16:55:45Z")

</div>

Thanks. I was under the impression that slf4j was just an abstraction layer, and picks up on a concrete implementation based on jar files found in your project. Is that not true?

I’ll look into logbacks, thanks.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [January 11, 2022, 5:02pm UTC](https://community.konduit.ai/t/nd4j-logging-bubbling-up/1742/6 "2022-01-11T17:02:01Z")

</div>

> [@wcneill](#):
>
> slf4j was just an abstraction layer, and picks up on a concrete implementation based on jar files found in your project.

You’ve got that right.

You don’t really have to move to logback, you just have to configure your log4j2 so it uses a lower log level for the nd4j namespace.
