我想使用属性计时功能.我想做这样的事情:
[TimeIt]
public MyFunc()
{
//do something
...
return;
}
Run Code Online (Sandbox Code Playgroud)
已在此功能的执行,如果由函数所花费的时间高于阈值,则属性应该使用log4net的日志的时间.
这类似于MVC ActionFilterAttribute所做的,除了我不想使用MVC.
这是我的 log4net.xml 文件
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\MVC2-" > </file>
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy'-'MM'-'dd'.log'" />
<dateTimeStrategy type="log4net.Appender.RollingFileAppender+UniversalDateTime" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%utcdate %level %property{requestId} %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
Run Code Online (Sandbox Code Playgroud)
日志日期采用 UTC,但文件会在服务器时间滚动到第二天。这会导致几个小时的日志记录在错误的文件中。
如何根据 UTC 时间使文件翻转?
我们用我们自己的 User 对象扩展了主体。这样,该对象对于每个请求都是可用的。当用户更新其信息时,主体需要使用这些新数据进行更新。当不使用 spring-session 时,此方法有效。然而,对于 spring-session 来说,情况并非如此。
我检查了 spring-session 代码,以及RedisOperationsSessionRepository:save(RedisSession session)唯一的调用session.saveDelta(),它仅保存更改的属性。那么,我们如何在会话中更新主体呢?
注意 - 更新主体的地方位于服务层,因此我们无权访问SessionAuthenticationStrategy.
这是场景 - 有多个应用服务器。浏览器可以通过 websocket 连接到任何应用服务器。
应用服务器(消费者)都在监听一个特定的队列。一旦接收到 Web 套接字连接,特定的应用程序服务器就会将带有路由键 {userId} 的队列绑定到直接交换。
我希望发送到带有路由密钥 {userId} 的直接交换的消息只能由发生绑定的特定应用服务器接收。
在这种情况下,直接交换是正确的交换吗?还是应该使用其他类型的交换?
当 websocket 进入时,我正在使用 spring-amqp 创建动态绑定
// create the RabbitMq queue and bind to it
String routingKey = MessageConstants.getRoutingKeyForUserRecommendationQueue(user);
Binding userRecommendationBinding = BindingBuilder.bind(userRecommendationsQueue).
to(directExchange).with(routingKey);
amqpAdmin.declareBinding(userRecommendationBinding);
Run Code Online (Sandbox Code Playgroud) 我们有一个不使用Spring会话的用例,即@EnableRedisHttpSession即使Spring Session和Spring boot在类路径中也没有注释。我们曾经通过拥有一个自定义属性spring.session.enabled并在具有注释@ConditionalOnProperty的类上使用来做到这一点@EnableRedisHttpSession。这在Spring Boot 1.2.7中有效。但是在Spring Boot 1.3.0中,SessionAutoConfiguration该类具有@EnableRedisHttpSession注释。
有没有办法禁止使用该类?
time ×2
.net ×1
attributes ×1
c# ×1
function ×1
log4net ×1
rabbitmq ×1
spring ×1
spring-amqp ×1
spring-boot ×1
utc ×1