我正在使用logback,我想打印一个时期时间戳而不是日期和时间。
https://logback.qos.ch/manual/layouts.html#contextName引用了https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html,无法将日期格式化为时代。
我不敢相信此基本功能不可用,但我搜索了一段时间,却找不到它。
对于log4j log4j : current time in milliseconds,我发现的是相同的问题,但是@thegeko的建议 import React, { Component } from 'react';
import { View, Text, TextInput,
FooterTab,Button,TouchableOpacity, ScrollView, StyleSheet,
ActivityIndicator ,Header,FlatList} from 'react-native';
import {Icon} from 'native-base';
import { createStackNavigator } from 'react-navigation';
import { SearchBar } from 'react-native-elements';
export default class RenderList extends Component {
static navigationOptions = {
title: 'Selected Item',
header: null,
};
constructor() {
super();
this.state = {
data: null,
loading: true,
search: '',
};
}
componentDidMount() {
this.createViewGroup();
}
createViewGroup = async () => {
try {
const response = await fetch(
'http://Dsenze/userapi/grouphier/viewgroup',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
password: 'admin',
username: 'admin',
viewall: 'false',
id: [4],
startlimit: '0',
valuelimit: '10',
}),
}
);
const responseJson = await response.json();
const { groupData } = responseJson;
this.setState({
data: groupData,
loading: false,
});
} catch (e) {
console.error(e);
}
};
clickedItemText(clickedItem) {
this.props.navigation.navigate('Item', { item: clickedItem });
}
updateSearch = search => {
this.setState({ search });
};
keyExtractor = ({ id }) => id.toString();
keyExtractor = ({ name }) => name.toString();
renderItem = ({ item }) => (
<TouchableOpacity
style={styles.item}
activeOpacity={0.4}
onPress={() => {
this.clickedItemText(item);
}}>
<Text>Hospital Id {item.id}</Text>
<Text>Hospital Name {item.name}</Text>
</TouchableOpacity>
);
renderSeparator = () => {
return (
<View
style={{
height: 1,
width: "86%",
backgroundColor: "#CED0CE",
}}
/>
);
};
render_FlatList_header = () => {
var header_View = (
<View style={styles.header_footer_style}>
<Text style={styles.textStyle}> FlatList Header </Text>
</View>
);
return header_View ;
};
render() {
const { loading, data } = this.state;
return (
<ScrollView>
<View style={styles.container1}>
{this.state.loading ? (
<ActivityIndicator size="large" />
) :
(
<FlatList
data={data}
renderItem={this.renderItem}
keyExtractor={this.keyExtractor}
ItemSeparatorComponent={this.renderSeparator}
ListHeaderComponent={this.render_FlatList_header}
/>
)}
</View>
</ScrollView>
);
}
}
在logback中对我不起作用。
有人知道吗?
答案 0 :(得分:1)
您可以使用此代码段打印Unix Epoch:
<layout class="net.logstash.logback.layout.LogstashLayout">
<timeZone>UTC</timeZone>
<timestampPattern>[UNIX_TIMESTAMP_AS_NUMBER]</timestampPattern>
</layout>
参考:https://github.com/logstash/logstash-logback-encoder#customizing-timestamp