Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java logback HTMLLayout页面太宽_Java_Html_Html Table_Logback - Fatal编程技术网

Java logback HTMLLayout页面太宽

Java logback HTMLLayout页面太宽,java,html,html-table,logback,Java,Html,Html Table,Logback,我将此布局与RollingFileAppender一起使用 一切都很好,但只有一个问题:通常生成的表的像素宽度太宽 这是因为我的许多测试方法名称通常很长。。。它们离开了窗口的右边缘,我不得不不断地左右滚动 我还使用了(Firefox)NoSquint插件,在这里,您可以缩放文本大小,几乎不受“常规缩放”的影响。但这并没有真正起作用。我只想为每个表列规定最大(和最小,为什么不?)像素宽度。任何感兴趣的人,我找到的解决方案是在输出的字符串中插入HTML软连字符(­;),其中包含驼峰大小写文本和

我将此布局与
RollingFileAppender
一起使用

一切都很好,但只有一个问题:通常生成的表的像素宽度太宽

这是因为我的许多测试方法名称通常很长。。。它们离开了窗口的右边缘,我不得不不断地左右滚动


我还使用了(Firefox)NoSquint插件,在这里,您可以缩放文本大小,几乎不受“常规缩放”的影响。但这并没有真正起作用。我只想为每个表列规定最大(和最小,为什么不?)像素宽度。

任何感兴趣的人,我找到的解决方案是在输出的
字符串中插入HTML软连字符(
­;
),其中包含驼峰大小写文本和/或点(也使文本变小)

-修改logback.xml和logback-test.xml文件,如下所示:

    <!--  <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">  -->
    <encoder class="utils.MyLayoutWrappingEncoder">
        <layout class="ch.qos.logback.classic.html.HTMLLayout">
            ....
以及:

public void doEncode(E事件)引发IOException{
String txt=layout.doLayout(事件);
/*
*识别所有输出中的“驼峰大小写”大写字母和点。。。
*并在此处插入软连字符。同时使文本变小。
*/
Pattern tDPattern=Pattern.compile((.*);
StringBuilder whisttringsb=新的StringBuilder();
Matcher tDMatcher=tDPattern.Matcher(txt);
int lastWhistString=0;
while(tDMatcher.find()){
字符串tDContents=tDMatcher.group(1);
Matcher camelCaseAndDotMatcher=Pattern.compile(“[a-z]”([a-z\\.])”).Matcher(tDContents);
StringBuilder camelCaseAndDotSB=新StringBuilder();
int last=0;
while(camelCaseAndDotMatcher.find()){
camelCaseAndDotSB.append(tDContents.substring(last,camelCaseAndDotMatcher.start(1));
camelCaseAndDotSB.append(“­;”+camelCaseAndDotMatcher.group(1));
last=camelCaseAndDotMatcher.end(1);
}
如果(上次>0){
//…至少发现一个驼峰案例UC char和/或dot。。。
append(txt.substring(lastWhistString,tDMatcher.start(1));
camelCaseAndDotSB.append(tDContents.substring(last));
append(camelCaseAndDotSB.toString().trim());
lastWhistString=tDMatcher.end();
}
}
append(txt.substring(lastWhistString.trim());
txt=whistringsb.toString();
//使文本变小
txt=txt.replaceAll(“,”);
write(convertToBytes(txt));
如果(立即冲洗)
outputStream.flush();
}
PS我还没有发现这些不同TD元素的各种“类”属性的CSS位于何处(或者,如果不是实际的文件,那么它们是如何生成的,等等)。有人知道吗

PPS虽然是一种很有前途的方法,但这些软连字符似乎并不适用于最后的“消息”列。需要更多的研究才能找到真正优秀的解决方案

void writeHeader() throws IOException {
    if (layout != null && (outputStream != null)) {
        StringBuilder sb = new StringBuilder();
        appendIfNotNull(sb, layout.getFileHeader());
        appendIfNotNull(sb, layout.getPresentationHeader());
        if (sb.length() > 0) {
            sb.append(CoreConstants.LINE_SEPARATOR);

            // replace a couple of header names with shorter and smaller text            
            String outString = sb.toString();
            outString = outString.replaceAll( "MethodOfCaller", "MoC" ).replaceAll( "RelativeTime", "RT" );
            outString = outString.replaceAll( "LineOfCaller", "LoC" );
            // make text smaller
            outString = outString.replaceAll( "<td class=(.+?)>", "<td style=\"font-size:13px\" class=$1>" );

            outputStream.write(convertToBytes( outString ));
            outputStream.flush();
        }
    }
}
public void doEncode(E event) throws IOException {
    String txt = layout.doLayout(event);

    /*
    * Identify "camel case" upper case letters and also dots in all <TD> output...
    * and insert soft hyphen at this point.  Also make text smaller.
    */
    Pattern tDPattern = Pattern.compile( "<td class=.+?>(.*?)</td>" );
    StringBuilder wholeStringSB = new StringBuilder();
    Matcher tDMatcher = tDPattern.matcher( txt );
    int lastWholeString = 0;
    while( tDMatcher.find() ){
        String tDContents = tDMatcher.group( 1 );
        Matcher camelCaseAndDotMatcher = Pattern.compile("[a-z]([A-Z\\.])").matcher( tDContents );
        StringBuilder camelCaseAndDotSB = new StringBuilder();
        int last = 0;
        while( camelCaseAndDotMatcher.find() ){
            camelCaseAndDotSB.append( tDContents.substring( last,  camelCaseAndDotMatcher.start( 1 ) ));
            camelCaseAndDotSB.append( "&shy;" + camelCaseAndDotMatcher.group(1) );
            last = camelCaseAndDotMatcher.end(1);
        }
        if( last > 0 ){
            // ... at least one camel case UC char and/or dot WAS found...
            wholeStringSB.append( txt.substring( lastWholeString,  tDMatcher.start( 1 )) );
            camelCaseAndDotSB.append( tDContents.substring(last));    
            wholeStringSB.append( camelCaseAndDotSB.toString().trim() );
            lastWholeString = tDMatcher.end();
        }
    }
    wholeStringSB.append( txt.substring( lastWholeString ).trim() );
    txt = wholeStringSB.toString();
    // make text smaller
    txt = txt.replaceAll( "<td class=(.+?)>", "<td style=\"font-size:13px\" class=$1>" );


    outputStream.write(convertToBytes(txt));
    if (immediateFlush)
        outputStream.flush();
}