GithubHelp home page GithubHelp logo

Comments (7)

ooooo84 avatar ooooo84 commented on June 12, 2024

如果将设置改为STDOUT_LOGGING就没有问题

from mybatis-log-plugin.

kookob avatar kookob commented on June 12, 2024

@ooooo84 方便的话,帮忙贴个文本串出来,可能不同的输出方式,存在一些特殊格式。

from mybatis-log-plugin.

ooooo84 avatar ooooo84 commented on June 12, 2024

十二月 29, 2018 8:18:10 上午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6fb554cc: startup date [Sat Dec 29 08:18:10 CST 2018]; root of context hierarchy
十二月 29, 2018 8:18:10 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2018-12-29 08:18:10,936 main DEBUG Apache Log4j Core 2.11.1 initializing configuration XmlConfiguration[location=D:\Code\MybatisPlusLearn\target\classes\log4j2.xml]
2018-12-29 08:18:10,944 main DEBUG Installed 2 script engines
2018-12-29 08:18:11,303 main DEBUG Oracle Nashorn version: 1.8.0_191, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
2018-12-29 08:18:11,346 main DEBUG BeanShell Engine version: 1.0, language: BeanShell, threading: MULTITHREADED, compile: true, names: [beanshell, bsh, java], factory class: bsh.engine.BshScriptEngineFactory
2018-12-29 08:18:11,347 main DEBUG PluginManager 'Core' found 117 plugins
2018-12-29 08:18:11,347 main DEBUG PluginManager 'Level' found 0 plugins
2018-12-29 08:18:11,351 main DEBUG PluginManager 'Lookup' found 13 plugins
2018-12-29 08:18:11,352 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2018-12-29 08:18:11,359 main DEBUG PluginManager 'TypeConverter' found 26 plugins
2018-12-29 08:18:11,371 main DEBUG PatternLayout$Builder(pattern="%m %n", PatternSelector=null, Configuration(D:\Code\MybatisPlusLearn\target\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2018-12-29 08:18:11,372 main DEBUG PluginManager 'Converter' found 44 plugins
2018-12-29 08:18:11,372 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
2018-12-29 08:18:11,379 main DEBUG ConsoleAppender$Builder(target="null", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%m %n), name="STDOUT", Configuration(D:\Code\MybatisPlusLearn\target\classes\log4j2.xml), Filter=null)
2018-12-29 08:18:11,380 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
2018-12-29 08:18:11,381 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2018-12-29 08:18:11,383 main DEBUG createAppenders(={STDOUT})
2018-12-29 08:18:11,384 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2018-12-29 08:18:11,387 main DEBUG createAppenderRef(ref="STDOUT", level="null", Filter=null)
2018-12-29 08:18:11,387 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2018-12-29 08:18:11,393 main DEBUG createLogger(additivity="null", level="DEBUG", includeLocation="null", ={STDOUT}, ={}, Configuration(D:\Code\MybatisPlusLearn\target\classes\log4j2.xml), Filter=null)
2018-12-29 08:18:11,395 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2018-12-29 08:18:11,396 main DEBUG createLoggers(={root})
2018-12-29 08:18:11,397 main DEBUG Configuration XmlConfiguration[location=D:\Code\MybatisPlusLearn\target\classes\log4j2.xml] initialized
2018-12-29 08:18:11,397 main DEBUG Starting configuration XmlConfiguration[location=D:\Code\MybatisPlusLearn\target\classes\log4j2.xml]
2018-12-29 08:18:11,398 main DEBUG Started configuration XmlConfiguration[location=D:\Code\MybatisPlusLearn\target\classes\log4j2.xml] OK.
2018-12-29 08:18:11,399 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2018-12-29 08:18:11,400 main DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2018-12-29 08:18:11,401 main DEBUG Appender DefaultConsole-1 stopped with status true
2018-12-29 08:18:11,401 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@15de0b3c OK
2018-12-29 08:18:11,447 main DEBUG Registering MBean org.apache.logging.log4j2:type=18b4aac2
2018-12-29 08:18:11,450 main DEBUG Registering MBean org.apache.logging.log4j2:type=18b4aac2,component=StatusLogger
2018-12-29 08:18:11,451 main DEBUG Registering MBean org.apache.logging.log4j2:type=18b4aac2,component=ContextSelector
2018-12-29 08:18:11,453 main DEBUG Registering MBean org.apache.logging.log4j2:type=18b4aac2,component=Loggers,name=
2018-12-29 08:18:11,455 main DEBUG Registering MBean org.apache.logging.log4j2:type=18b4aac2,component=Appenders,name=STDOUT
2018-12-29 08:18:11,457 main DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
2018-12-29 08:18:11,458 main DEBUG Reconfiguration complete for context[name=18b4aac2] at URI D:\Code\MybatisPlusLearn\target\classes\log4j2.xml (org.apache.logging.log4j.core.LoggerContext@388526fb) with optional ClassLoader: null
2018-12-29 08:18:11,458 main DEBUG Shutdown hook enabled. Registering a new one.
2018-12-29 08:18:11,459 main DEBUG LoggerContext[name=18b4aac2, org.apache.logging.log4j.core.LoggerContext@388526fb] started OK.
{dataSource-1} inited
_ _ |_ _ |. ___ _ | _
| | |/|)(| | |\ |)|||\
/ |
3.0.6
Logging initialized using 'class org.apache.ibatis.logging.log4j2.Log4j2Impl' adapter. Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b0a7baf] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@7e094740] will not be managed by Spring
==> Preparing: INSERT INTO tbl_employee ( last_name, email, gender, age ) VALUES ( ?, ?, ?, ? )
==> Parameters: Scott(String), [email protected](String), 1(Integer), 23(Integer)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b0a7baf]
1
Employee{id=10, lastName='Scott', email='[email protected]', gender=1, age=23}

===============================================
Default Suite
Total tests run: 1, Failures: 0, Skips: 0

2018-12-29 08:18:12,484 pool-1-thread-1 DEBUG Stopping LoggerContext[name=18b4aac2, org.apache.logging.log4j.core.LoggerContext@388526fb]
2018-12-29 08:18:12,484 pool-1-thread-1 DEBUG Stopping LoggerContext[name=18b4aac2, org.apache.logging.log4j.core.LoggerContext@388526fb]...
2018-12-29 08:18:12,486 pool-1-thread-1 DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false
2018-12-29 08:18:12,487 pool-1-thread-1 DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false, all resources released: true
2018-12-29 08:18:12,487 pool-1-thread-1 DEBUG Appender STDOUT stopped with status true
2018-12-29 08:18:12,488 pool-1-thread-1 DEBUG Stopped XmlConfiguration[location=D:\Code\MybatisPlusLearn\target\classes\log4j2.xml] OK
2018-12-29 08:18:12,488 pool-1-thread-1 DEBUG Stopped LoggerContext[name=18b4aac2, org.apache.logging.log4j.core.LoggerContext@388526fb] with status true

Process finished with exit code 0

from mybatis-log-plugin.

kookob avatar kookob commented on June 12, 2024

@ooooo84 你这个是LOG4J2的吗?我验证是可以解析正常的,无法复现,你那边是每次都报:
”Can't restore sql from selection.“ 这个吗?多验证几次看看。

from mybatis-log-plugin.

ooooo84 avatar ooooo84 commented on June 12, 2024

我知道是什么原因了,出问题的log4j2的配置为:
<PatternLayout pattern="%m %n"/>
把空格去了,改成
<PatternLayout pattern="%m%n"/>
就正常了

from mybatis-log-plugin.

kookob avatar kookob commented on June 12, 2024

@ooooo84 嗯,是这个问题,这个问题很有代表性,很多插件不起作用可能是这个原因引起的。
解释一下:
主要是第二行的参数解析,在N多用户跑的各种项目的过程中,参数格式多种多样,比如富文本的,字符串包含换行的,包含(String), (Long), null 关键字等等等等。
要统一正确解析要涉及到各种格式判断,所以参数行如果以空格结束,会判断不出是已经结束还是换行的参数。
所以 %msg%n 这个配置大家要注意,不能带有空格,而且正确的配置也不应该带空格。

from mybatis-log-plugin.

jingshenbusi6530 avatar jingshenbusi6530 commented on June 12, 2024

环境是:springboot 2.x and mybatis-log-plugin 2.0.7 and logback
选中sql,然后右键“Restore Sql from Selection”,会出“Can't restore sql from selection”,但是项目重启后,刚才选中的sql,就能输出出来。

from mybatis-log-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.