Ich habe diese Zeile hinzugefügtDropwizard Jersey Logging Anfrage/Antwort als Fehler, aber warum?
environment.jersey().register(new LoggingFeature(Logger
.getLogger(LoggingFeature.class.getName()), Level.OFF,
LoggingFeature.Verbosity.PAYLOAD_TEXT, null));
in meiner run(Configuration configuration, Environment environment)
Methode bei und this suche
ich nur Sachen immer in den Protokollen bin, wenn die Level
zu OFF
und all meinen Wünschen gesetzt/Antwort-Meldungen sind als Fehler protokolliert, aber warum Fehler?
Hier ist ein Beispiel für das Protokoll:
ERROR [11:17:41.603] [dw-31 - GET /helloworld] o.g.j.l.LoggingFeature - 1
* Server has received a request on thread dw-31 - GET /helloworld
1 > GET http://localhost:8080/helloworld
1 > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
1 > Accept-Encoding: gzip, deflate, sdch, br
1 > Accept-Language: en-US,en;q=0.8
1 > Cache-Control: max-age=0
1 > Connection: keep-alive
1 > Cookie: openid_provider=openid; _ga=GA1.1.1009619719.1483436711
1 > Host: localhost:8080
1 > Upgrade-Insecure-Requests: 1
1 > User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36
ERROR [11:17:41.615] [dw-31 - GET /helloworld] o.g.j.l.LoggingFeature - 1 * Server responded with a response on thread dw-31 - GET /helloworld
1 < 200
Meine Ressourcenklasse:
@Path("/helloworld")
@Produces(MediaType.APPLICATION_JSON)
public class HelloWorldResource {
public HelloWorldResource() { }
@GET
public Response helloWorld(){
System.out.println("Hello World");
return Response.ok().build();
}
}
Meine Hauptanwendungsklasse:
public class ApiApplication extends Application<ApiConfiguration>{
public static void main(String[] args) throws Exception{
new ApiApplication().run(args);
}
@Override
public void initialize(Bootstrap<ApiConfiguration> bootstrap) {
// nothing to do yet
}
@Override
public void run(ApiConfiguration apiConfiguration, Environment environment) throws Exception {
final TemplateHealthCheck healthCheck =
new TemplateHealthCheck(apiConfiguration.getTemplate());
environment.healthChecks().register("template", healthCheck);
final HelloWorldResource helloWorldResource = new HelloWorldResource();
final JerseyEnvironment jerseyEnvironment = environment.jersey();
jerseyEnvironment.register(helloWorldResource);
jerseyEnvironment.register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.OFF, LoggingFeature.Verbosity.PAYLOAD_ANY, Integer.MAX_VALUE));
}
}
Dank es half, nun, ich konnte mich nicht darum kümmern, dass Protokolle erstellt wurden, wenn sie auf "OFF" gestellt wurden, aber nichts wurde erzeugt, wenn auf "ALL" gestellt wurde. Es kam mir nicht in den Sinn, 'FINE' auszuprobieren. Ich versuche nur herauszufinden, wie man loggt, wenn eine bestimmte Anfrage von einem bestimmten Benutzer angerufen wird. Aber vielen Dank für die Erklärung @nullpointer – TheLearner
@TheLearner Ich bin nicht sehr sicher, wo das derzeit gehört. Dies sollte jedoch als unerwartetes Verhalten (Bug) bei einer der beteiligten Bibliotheken auftreten. – nullpointer
Ich werde es so bald wie möglich melden – TheLearner