如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)

问题描述

=====================

经常需要在SharePoint的ULS日志中捞取一些带有callstack的信息, 而且需要把callstack展开细细查看. 然而, ULS log中的callstack是挤在一起的, 查看起来很不方便.

笔者原来一直手工添加换行符, 但是近期这类工作实在有点多, 于是开始想办法了.

 

问题举例, 笔者从ULS log中捞到这个CallStack,

Error while executing web part: Microsoft.BusinessData.Infrastructure.BdcException: The shim execution failed unexpectedly - Target application not found (application id: AdventureApp).. ---> Microsoft.Office.SecureStoreService.Server.SecureStoreServiceTargetApplicationNotFoundException: Target application not found (application id: AdventureApp).     at Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplicationProxy.Execute[T](String operationName, Boolean validateCanary, ExecuteDelegate`1 operation)     at Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplicationProxy.GetRestrictedCredentials(Guid rawPartitionId, String applicationId)     at Microsoft.Office.SecureStoreService.Server.SecureStoreProvider.GetRestrictedCredentials(String appId)     at Microsoft....
...SharePoint.BusinessData.SystemSpecific.Db.DbConnectionManager.GetConnection()     at Microsoft.SharePoint.BusinessData.SystemSpecific.Db.DbSystemUtility.ExecuteStatic(IMethodInstance methodInstance, ILobSystemInstance lobSystemInstance, Object[] args, IExecutionContext context)     at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternalWithAuthNFailureRetry(ISystemUtility systemUtility, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IParameterCollection nonReturnParameters, Object[] overrideArgs)     at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanc...
...eToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.BusinessData.Runtime.DataClassRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs)     at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.ExecuteInternal(IDataClass thisDataClass, ILobSystemInstance lobSystemInstance, ILobSystem lobSystem, IMethodInstance methodInstanceToExecute, IMethod methodToExecute, IParameterCollection nonReturnParameters, Object[]& overrideArgs, IFilterCollection filters)     at Microsoft.SharePoin...
...t.BusinessData.Runtime.EntityRuntime.ExecuteFiltered(IEntity this, IFilterCollection filterCollection, IMethodInstance methodInstanceToExecute, ILobSystemInstance lobSystemInstance)     at Microsoft.SharePoint.BusinessData.Runtime.EntityRuntime.<FindFiltered>b__3(IEntity e, IMethodInstance mi, IFilterCollection fc, ILobSystemInstance lsi)     at Microsoft.SharePoint.BusinessData.Runtime.EntityInstanceEnumeratorFactory.CreateEntityInstanceEnumerator(IEntity entity, IMethodInstance methodInstance, IFilterCollection filters, ILobSystemInstance lobSystemInstance, ExecutionCallBack executionCallBack)     at Microsoft.SharePoint.BusinessData.MetadataModel.Static.Entity.FindFiltered(IFilterCollection filterCollection, String finderName, ILobSystemInstance lobSystemInstance)     at Microsoft.Share...
...Point.SPListDataSource.GetEntityInstanceEnumerator(XmlNode xnMethodAndFilters)     at Microsoft.SharePoint.SPListDataSource.GetFilteredEntityInstancesInternal(XmlDocument xdQueryView, Boolean fFormatDates, Boolean fUTCToLocal, String firstRowId, Boolean fBackwardsPaging, String& bdcidFirstRow, String& bdcidNextPageRow, List`1& lstColumnNames, Dictionary`2& dictColumnsUsed, List`1& mapRowOrdering, List`1& lstEntityData)     at Microsoft.SharePoint.SPListDataSource.GetFilteredEntityInstances(XmlDocument xdQueryView, Boolean fFormatDates, Boolean fUTCToLocal, String firstRowId, Boolean fBackwardsPaging, String& bdcidFirstRow, String& bdcidNextPageRow, List`1& lstColumnNames, Dictionary`2& dictColumnsUsed, List`1& mapRowOrdering, List`1& lstEntityData)     at Microsoft.SharePoint.SPListItemCol...
...lection.EnsureEntityDataViewAndOrdering(String& bdcidFirstRow, String& bdcidNextPageFirstRow)     at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()     at Microsoft.SharePoint.SPListItemCollection.get_Count()     at Microsoft.SharePoint.WebControls.SPDataSourceView.ExecuteSelect(DataSourceSelectArguments selectArguments, String aggregateString, Boolean wantReturn, BaseXsltListWebPart webpart, SPListItem& listItem, SPListItemCollection& listItems, String[]& fieldList)     at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigatorInternal()     at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigator()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)

研究

=====================

在Notepad++中新建一个文件, 随便输入几行文字

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第1张图片

 

点击下面的选项

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第2张图片

 

结果如下, 显然CR, LF是换行符.

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第3张图片

 

使用CR, LF, Notepad++作为关键字, 经过搜索, 在Notepad++的官网上找到了如下的文字:

Ctrl+H with Extended option selected instead of Regexp. Search for "\r\n", or whatever your OS uses, and replace with what you need. It will replace the newline characters with what you entered. Note that Windows uses CR-LF newlines (\r\n), old Mac uses CR (\r) and Unix uses LF (\n). You can use View -> Show Symbol -> Show End Of Line to see which characters your file uses - files from other OSes may not behave as you expect because they have a different newline type.

Some examples: - To add a string to the end of all lines in Windows, in Ctrl+H with Extended mode enabled, replace \r\n with string\r\n - To add a string to the beginning of all lines in windows, in Ctrl+H with Extended mode enabled, replace \r\n with \r\nstring - To remove extra blank lines in windows, in Ctrl+H with Extended mode enabled, replace \r\n\r\n with \r\n - To remove all newlines, in Ctrl+H with Extended mode enabled, replace \r\n with nothing.

 

解决方案

=====================

使用Notepad++, 将内容贴入:

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第4张图片

 

呼出替换对话框, 将<at>替换为<\r\nat>, 不包括尖括号.

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第5张图片

 

结果如下:

如何使用Notepad++快速整理挤在一起的CallStack信息(将换行符作为被替换的内容)_第6张图片

 

就用这个技巧作为开端吧, 善用notepad++, 让工作效率疾驰如飞.

 

参考资料

=====================

How To Replace Line Ends, thus changing the line layout

http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Newlines

Replace a "comma space" with a new line in notepad++

http://pressf1.co.nz/showthread.php?t=91763

你可能感兴趣的:(notepad)