简体   繁体   English

如何在 Javalin 5 中启用“开发日志记录”?

[英]How to enable "dev logging" in Javalin 5?

There have been a lot of changes to the configuration in Javalin 5. One thing that used to work in previous versions is to enable "dev logging": Javalin 5 中的配置发生了很多变化。在以前的版本中使用的一件事是启用“开发日志记录”:

var javalin = Javalin.create(cfg -> {
               cfg.enableDevLogging();
              }).start(8080);

But I cannot seem to find this setting in version 5. So the question is, how do you enable "dev logging" in Javalin version 5?但我似乎无法在版本 5 中找到此设置。所以问题是,如何在 Javalin 版本 5 中启用“开发日志记录”?

You can enable this via 'DevLoggingPlugin'您可以通过“DevLoggingPlugin”启用此功能

Javalin.create(config -> {
    config.plugins.enableDevLogging(); // Approach 1
    config.plugins.register(new DevLoggingPlugin()); // Approach 2
});

NOTE: You * DO NOT * need to use both the lines in above config (Commented 'Approach 1' and 'Approach 2').注意:您 * 不需要 * 需要同时使用上述配置中的两行(注释为“方法 1”和“方法 2”)。 Just pick an approach that fits your style.只需选择适合您风格的方法即可。

Refer to the Javalin docs for this plugin - https://javalin.io/plugins/devlogging请参阅此插件的 Javalin 文档 - https://javalin.io/plugins/devlogging

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM