Comments (9)
Here is Java code of the above for lazy people, the imports are the same. :
Set<String> loggers = new HashSet<>(Arrays.asList("org.apache.http", "groovyx.net.http"));
for(String log:loggers) {
Logger logger = (Logger)LoggerFactory.getLogger(log);
logger.setLevel(Level.INFO);
logger.setAdditive(false);
}
However, this does not work in gnome-terminal because of this error:
org.slf4j.impl.SimpleLogger cannot be cast to ch.qos.logback.classic.Logger
from artifactory-client-java.
Create a logback.xml with below contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="org.apache" level="ERROR" />
<logger name="httpclient" level="ERROR" />
</configuration>
Then put this logback.xml in your java source dir so it will be included in jar file. Otherwise create a jar from logback.xml and put this jar to your lib where you fetch all your jars.
A simple way to create logback.jar from logback.xml is using ant.
Create build.xml with below code:
<?xml version='1.0'?>
<project name="test" default="compile" basedir=".">
<target name = "build-jar">
<jar destfile = "op/logback.jar"
basedir = "in">
<manifest>
<attribute name = "Main-Class" value = "com.tutorialspoint.util.FaxUtil"/>
</manifest>
</jar>
</target>
</project>
Create a directory structure like:
.
|-- build.xml
|-- in --> logback.xml
|-- op --> logback.jar //This will be generated after execution of ant command
Now compile using ant build-jar
You will have logback.jar. Put this jar with all other jars and it will remove org.apache.http.wire DEBUG log
Thanks.
from artifactory-client-java.
Piggy-backing off of @terrytheplatypus and the code there, in order to avoid conflicts with using Java's util logger (or other logger you may be using), you can instead explicitly include the package like this:
Set<String> artifactoryLoggers = new HashSet<>(Arrays.asList("org.apache.http", "groovyx.net.http"));
for(String log:artifactoryLoggers) {
ch.qos.logback.classic.Logger artLogger = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(log);
artLogger.setLevel(ch.qos.logback.classic.Level.INFO);
artLogger.setAdditive(false);
}
from artifactory-client-java.
you can configure logback with a config file like this on logback.xml
If you want to disable programmatically, you can use this sample code (it's in scala, but java will be very similar):
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
val loggers = Seq(
"org.apache.http",
"groovyx.net.http"
)
loggers.foreach { name =>
val logger = LoggerFactory.getLogger(name).asInstanceOf[Logger]
logger.setLevel(Level.INFO)
logger.setAdditive(false)
}
from artifactory-client-java.
Set<String> artifactoryLoggers = new HashSet<>(Arrays.asList("org.apache.http", "groovyx.net.http")); for(String log:artifactoryLoggers) { ch.qos.logback.classic.Logger artLogger = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(log); artLogger.setLevel(ch.qos.logback.classic.Level.INFO); artLogger.setAdditive(false); }
@Dougnlizt Is there a logback config file setting to make this work?
Sadly, the following doesn't work for me even though the above programmatic setting does:
<logger name="org.apache.http" level="INFO" additive="false"/>
<logger name="groovyx.net.http" level="INFO" additive="false"/>
Even bumping my root log level up to INFO in the logback config file fails to stop these DEBUG logs.
from artifactory-client-java.
it works for me . Thanks @terrytheplatypus
from artifactory-client-java.
Very helpful,thank you. @Dougnlizt
from artifactory-client-java.
Create a logback.xml with below contents:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <logger name="org.apache" level="ERROR" /> <logger name="httpclient" level="ERROR" /> </configuration>
Then put this logback.xml in your java source dir so it will be included in jar file. Otherwise create a jar from logback.xml and put this jar to your lib where you fetch all your jars.
A simple way to create logback.jar from logback.xml is using ant.
Create build.xml with below code:<?xml version='1.0'?> <project name="test" default="compile" basedir="."> <target name = "build-jar"> <jar destfile = "op/logback.jar" basedir = "in"> <manifest> <attribute name = "Main-Class" value = "com.tutorialspoint.util.FaxUtil"/> </manifest> </jar> </target> </project>
Create a directory structure like:
.
|-- build.xml
|-- in --> logback.xml
|-- op --> logback.jar //This will be generated after execution of ant commandNow compile using ant build-jar
You will have logback.jar. Put this jar with all other jars and it will remove org.apache.http.wire DEBUG logThanks.
Awesome. This saved me
from artifactory-client-java.
@milind94 It did not work for me. I created the logback.xml file with exactly same content and added in resource folder and created jar file but I still see those logs
from artifactory-client-java.
Related Issues (20)
- Allow to retrieve artifact File Statistics
- DockerRepositorySettingsImpl missing setter for dockerTagRetention repository property
- Is it possible to push a docker image saved using docker save command using this java client? HOT 1
- Add support for Terraform package type HOT 1
- False positive on CVE-2020-16156
- Repository upload() does not handle UTF-8 Strings as path names
- Unable to implment Artifactory Rest API in intellij java springboot service - Cannot access groovy.lang.GroovyObject HOT 3
- Illegal reflective access warnings with Java version 11 or later HOT 1
- False Positive on CVE-2014-0114
- Using in Android causes a "No static field" HOT 6
- In Firefox the web signup with Google spins here for ever HOT 2
- Android quality
- There are no tags for a release
- Fails to upload artifact greater than 4GB in size HOT 1
- DockerRepositorySettingsImpl Missing blockPushingSchema1 Repository Property
- Migration to apache.hc.core5 for Spring-Boot-3 HOT 1
- Is there a possibility to rest call with HEAD method
- Support for the JFrog Platform's Projects REST API
- Add missing xrayDataTtl field to XraySettings
- groovy.lang.MissingMethodException: No signature of method: org.jfrog.artifactory.client.impl.ArtifactBase.withProperty() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from artifactory-client-java.