如何在Spring Integration应用程序中停止Spring框架日志

时间:2019-03-04 20:28:57

标签: spring spring-boot spring-integration

我需要停止框架日志。我需要打印应用程序日志而不是框架日志。我们正在对应用程序使用spring boot和spring集成,并使用线陷阱记录请求。我可以更改日志记录级别(logging.level.org.springframework = WARN)以停止框架日志,但是当我这样做时,我的应用程序日志也不会打印。有什么办法可以阻止框架日志的打印。

<int:channel id="arrowEyeRequest">
    <int:interceptors>
        <int:wire-tap channel="arrowEyeTransformedRequestLogger" />
    </int:interceptors>
</int:channel>

<int:logging-channel-adapter id="arrowEyeTransformedRequestLogger" expression="'ArrowEye(FP-024)---- transformed ArrowEye request---- \n'.concat(payload)" level="INFO" />

1 个答案:

答案 0 :(得分:0)

logger-name具有 <xsd:attribute name="logger-name" type="xsd:string"> <xsd:annotation> <xsd:documentation> Provide a name for the logger. This is useful when there are multiple logging Channel Adapters configured, and you would like to differentiate them within the actual log. By default the logger name will be the fully qualified class name of the LoggingHandler implementation. </xsd:documentation> </xsd:annotation> </xsd:attribute> 属性:

logging.level.org.springframework=WARN

因此,即使您拥有logging.level.myLogger=INFO,您仍然可以配置类似<int:logging-channel-adapter id="arrowEyeTransformedRequestLogger" expression="'ArrowEye(FP-024)---- transformed ArrowEye request---- \n'.concat(payload)" logger-name="myLogger" level="INFO" /> 的东西并将其存储在通道适配器中:

for root, dirs, files in os.walk(input_location):
    for name in files:
        file_path = os.path.join(root, name) # joins the new path of the file to the current file in order to access the file

        filestring = ''
        with open(file_path, 'r') as f: # open the file
            for line in f: # read file line by line
                x = remove_stop_words(line,stopwords)
                filestring+=x
                filestring+='\n' #Create new line

        new_file_path = os.path.join(output_location, name) + '_filtered' # creates a new file of the file that is currenlty being filtered of stopwords
        with open(new_file_path, 'a') as output_file: # opens output file
            output_file.write(filestring) # writes the newly filtered text to the new output file