草庐IT

sysout-over-slf

全部标签

java - Eclipse RCP 插件中的多个 slf4j 绑定(bind)

我有一个简单的Eclipse插件,在激活时会出现以下错误:SLF4J:ClasspathcontainsmultipleSLF4Jbindings.SLF4J:Foundbindingin[bundleresource://103.fwk8918249:1/org/slf4j/impl/StaticLoggerBinder.class]SLF4J:Foundbindingin[bundleresource://103.fwk8918249:4/org/slf4j/impl/StaticLoggerBinder.class]SLF4J:Seehttp://www.slf4j.org/co

java - 如何使用 SLF4JBridgeHandler 以编程方式设置 slf4j 记录器

我正在尝试设置slf4j以拦截所有日志记录语句,然后根据特定条件以编程方式添加处理程序。我的代码是:privatevoidinit(){SLF4JBridgeHandler.removeHandlersForRootLogger();SLF4JBridgeHandler.install();if(condition1)appendHandler(console,Level.DEBUG);if(condition2)appendHandler(logfile1,Level.INFO);...}如何编写appendHandler方法的代码?我刚刚花了几个小时试图通读文档,但找不到解决方案。

java - 是否可以在使用 Java 9 的 Eclipse IDE 中使用没有类和主要方法的 sysout?

由于Java9引入了JShell的概念,使得我们可以在不创建类和方法的情况下编写代码,是否可以在eclipse中使用Java9的这一特性? 最佳答案 您可以使用TMTerminal在Eclipse中运行JShell:如有必要,安装TMTerminal(仅包含在某些Eclipse包中)在Eclipse中打开“终端”View:Window>ShowView>Other...:Terminal>Terminal启动一个新的本地终端运行JShell,e.G。在Windows上键入"C:\ProgramFiles\Java\jdk-9\bin

java - JSTL 消息 : Don't know how to iterate over supplied "items" with forEach

我正在将一个列表传递给,但我收到错误消息,指出它不知道如何对其进行迭代。@RequestMapping("/viewall")publicStringviewAll(Modelmodel){//productService.findAllProducts()returnsListmodel.addAttribute("everything",productService.findAllProducts());//Alsotriedusingiterator,butIgetsameerror//model.addAtrribute("everything",productService.

java - 得到一个虚拟的 slf4j 记录器?

我可以从slf4j获得虚拟记录器吗?(想想空对象设计模式。)如果是这样,有人可以提供一个例子吗?或者,如果我想这样做,我是否必须实现自定义记录器?我希望按照以下方式编写一个函数privateLoggerlogger;staticLoggernullLogger;static{nullLogger=getMeADummyLogger();}publicLoggergetLogger(){returnthis.logger==null?nullLogger:this.logger;}//then,elsewhere:this.getLogger().info("somethingjusth

java - SLF4J 错误 : class loader have different class objects for the type

试图弄清楚为什么我在tomcat日志中收到以下错误:Causedby:java.lang.LinkageError:loaderconstraintviolation:whenresolvingmethod"org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;"theclassloader(instanceoforg/apache/catalina/loader/WebappClassLoader)ofthecurrentclass,org/slf4j/LoggerFactory,a

Java : ConcurrentModificationException while iterating over list

这个问题在这里已经有了答案:IteratingthroughaCollection,avoidingConcurrentModificationExceptionwhenremovingobjectsinaloop(31个答案)WhyisaConcurrentModificationExceptionthrownandhowtodebugit(8个答案)关闭3年前。当我执行下面的代码时,我得到了ConcurrentModificationExceptionCollectionmyCollection=Collections.synchronizedList(newArrayList(1

java - 为什么 sysout 不起作用?

我检查了我的Eclipse中的首选项设置,它全部设置为默认值并启用了sysout选项,但是当我在Eclipse中键入sysout时,它不会自动进入System.out.println()。我检查了其他几个提到ctrl+space的相关主题。这是我电脑上输入法的快捷方式。不知道是不是和我无法使用sysout有关。如果没有,请告诉我如何让我的sysout工作。如果是,请告诉我如何重置“ctrl+space”或为内容助手设置其他快捷方式。 最佳答案 Eclipse>Preferences>Java>Editor>ContentAssist

java - 将org.slf4j.MDC与Netty channel 一起使用?

实际上,我想做的是HowtouseMDCwiththreadpools?所要问的,但要与Netty一起。我想要每个Channel关联的MDC信息。Netty有哪些选择?如果我需要手动重置MDC,可以使用哪种方法从一个地方进行重置? 最佳答案 看看GitHub上的mdedetrich/mdc-async-netty-eventloopgroup项目。基本上,您必须装饰EventLoopGroup.execute@Overridepublicvoidexecute(Runnablerunnable){delegate.execute(n

java - 从纯客户端调用远程 EJB(RMI over IIOP)时如何传播 JAAS Subject

我正在测试JAASSubject的传播用customPrincipal从运行在原始Java运行时上的独立EJB客户端到JavaEE服务器。我同时针对JBoss和WebSphere实现。根据thisforumthread我曾预计它会很容易地与JBoss一起工作。这是我的EJB客户端代码片段:Subjectsubject=newSubject();PrincipalmyPrincipal=newMyPrincipal("meImyself");subject.getPrincipals().add(myPrincipal);PrivilegedExceptionActionaction=n